Merge pull request #750 from MikeTheWatchGuy/Dev-latest
0.12.0, restructure folders, multi-window design patterns
This commit is contained in:
commit
39ffd75422
|
@ -0,0 +1,59 @@
|
|||
import sys
|
||||
if sys.version_info[0] >= 3:
|
||||
import PySimpleGUIQt as sg
|
||||
else:
|
||||
import PySimpleGUI27 as sg
|
||||
|
||||
"""
|
||||
Demo - Running 2 windows with both being active at the same time
|
||||
Three important things to note about this design patter:
|
||||
1. The layout for window 2 is inside of the while loop, just before the call to window2=sg.Window
|
||||
2. The read calls have timeout values of 100 and 0. You can change the 100 to whatever interval you wish
|
||||
but must keep the second window's timeout at 0
|
||||
3. There is a safeguard to stop from launching multiple copies of window2. Only 1 window2 is visible at a time
|
||||
"""
|
||||
|
||||
# Window 1 layout
|
||||
layout = [
|
||||
[sg.Text('This is the FIRST WINDOW'), sg.Text(' ', key='_OUTPUT_')],
|
||||
[sg.Text('')],
|
||||
[sg.Button('Launch 2nd Window'),sg.Button('Popup'), sg.Button('Exit')]
|
||||
]
|
||||
|
||||
window = sg.Window('Window Title', location=(800,600)).Layout(layout)
|
||||
win2_active = False
|
||||
i=0
|
||||
while True: # Event Loop
|
||||
event, values = window.Read(timeout=100)
|
||||
if event != sg.TIMEOUT_KEY:
|
||||
print(i, event, values)
|
||||
|
||||
if event is None or event == 'Exit':
|
||||
break
|
||||
elif event == 'Popup':
|
||||
sg.Popup('This is a BLOCKING popup','all windows remain inactive while popup active')
|
||||
i+=1
|
||||
if event == 'Launch 2nd Window' and not win2_active: # only run if not already showing a window2
|
||||
win2_active = True
|
||||
# window 2 layout - note - must be "new" every time a window is created
|
||||
layout2 = [
|
||||
[sg.Text('The second window'), sg.Text('', key='_OUTPUT_')],
|
||||
[sg.Input(do_not_clear=True, key='_IN_')],
|
||||
[sg.Button('Show'), sg.Button('Exit')]
|
||||
]
|
||||
window2 = sg.Window('Second Window').Layout(layout2)
|
||||
# Read window 2's events. Must use timeout of 0
|
||||
if win2_active:
|
||||
# print("reading 2")
|
||||
event, values = window2.Read(timeout=100)
|
||||
# print("win2 ", event)
|
||||
if event != sg.TIMEOUT_KEY:
|
||||
print("win2 ", event)
|
||||
if event == 'Exit' or event is None:
|
||||
# print("Closing window 2", event)
|
||||
win2_active = False
|
||||
window2.Close()
|
||||
if event == 'Show':
|
||||
sg.Popup('You entered ', values['_IN_'])
|
||||
|
||||
window.Close()
|
|
@ -0,0 +1,35 @@
|
|||
"""
|
||||
PySimpleGUI The Complete Course
|
||||
Lesson 7 - Multiple Windows
|
||||
"""
|
||||
import PySimpleGUIQt as sg
|
||||
|
||||
# Design pattern 1 - First window does not remain active
|
||||
|
||||
layout = [[ sg.Text('Window 1'),],
|
||||
[sg.Input(do_not_clear=True)],
|
||||
[sg.Text('', key='_OUTPUT_')],
|
||||
[sg.Button('Launch 2')]]
|
||||
|
||||
win1 = sg.Window('Window 1').Layout(layout)
|
||||
win2_active=False
|
||||
while True:
|
||||
ev1, vals1 = win1.Read(timeout=100)
|
||||
if ev1 is None:
|
||||
break
|
||||
win1.FindElement('_OUTPUT_').Update(vals1[0])
|
||||
|
||||
if ev1 == 'Launch 2' and not win2_active:
|
||||
win2_active = True
|
||||
win1.Disappear()
|
||||
layout2 = [[sg.Text('Window 2')],
|
||||
[sg.Button('Exit')]]
|
||||
|
||||
win2 = sg.Window('Window 2').Layout(layout2)
|
||||
while True:
|
||||
ev2, vals2 = win2.Read()
|
||||
if ev2 is None or ev2 == 'Exit':
|
||||
win2.Close()
|
||||
win2_active = False
|
||||
win1.Reappear()
|
||||
break
|
|
@ -0,0 +1,34 @@
|
|||
"""
|
||||
PySimpleGUI The Complete Course
|
||||
Lesson 7 - Multiple Windows
|
||||
"""
|
||||
import PySimpleGUI as sg
|
||||
|
||||
# Design pattern 2 - First window remains active
|
||||
|
||||
layout = [[ sg.Text('Window 1'),],
|
||||
[sg.Input(do_not_clear=True)],
|
||||
[sg.Text('', key='_OUTPUT_')],
|
||||
[sg.Button('Launch 2'), sg.Button('Exit')]]
|
||||
|
||||
win1 = sg.Window('Window 1').Layout(layout)
|
||||
|
||||
win2_active = False
|
||||
while True:
|
||||
ev1, vals1 = win1.Read(timeout=100)
|
||||
win1.FindElement('_OUTPUT_').Update(vals1[0])
|
||||
if ev1 is None or ev1 == 'Exit':
|
||||
break
|
||||
|
||||
if not win2_active and ev1 == 'Launch 2':
|
||||
win2_active = True
|
||||
layout2 = [[sg.Text('Window 2')],
|
||||
[sg.Button('Exit')]]
|
||||
|
||||
win2 = sg.Window('Window 2').Layout(layout2)
|
||||
|
||||
if win2_active:
|
||||
ev2, vals2 = win2.Read(timeout=100)
|
||||
if ev2 is None or ev2 == 'Exit':
|
||||
win2_active = False
|
||||
win2.Close()
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
@ -487,7 +487,8 @@ class InputText(Element):
|
|||
self.DefaultText = value
|
||||
|
||||
def Get(self):
|
||||
return self.TKStringVar.get()
|
||||
return self.QT_QLineEdit.text()
|
||||
# return self.TKStringVar.get()
|
||||
|
||||
def SetFocus(self):
|
||||
try:
|
||||
|
@ -1160,6 +1161,8 @@ class Output(Element):
|
|||
# self.my_stdout.write(str(m))
|
||||
|
||||
def __del__(self):
|
||||
sys.stdout = self.my_stdout
|
||||
sys.stderr = self.my_stderr
|
||||
super().__del__()
|
||||
|
||||
|
||||
|
@ -3042,7 +3045,7 @@ class Window:
|
|||
:return:
|
||||
'''
|
||||
self._AlphaChannel = alpha
|
||||
if self._AlphaChannel:
|
||||
if self._AlphaChannel is not None:
|
||||
self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel)
|
||||
|
||||
@property
|
||||
|
@ -3052,7 +3055,7 @@ class Window:
|
|||
@AlphaChannel.setter
|
||||
def AlphaChannel(self, alpha):
|
||||
self._AlphaChannel = alpha
|
||||
if self._AlphaChannel:
|
||||
if self._AlphaChannel is not None:
|
||||
self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel)
|
||||
|
||||
def BringToFront(self):
|
||||
|
@ -3124,7 +3127,7 @@ class Window:
|
|||
return QWidget.eventFilter(self, widget, event)
|
||||
|
||||
def closeEvent(self, event):
|
||||
print('GOT A CLOSE EVENT!', event)
|
||||
# print('GOT A CLOSE EVENT!', event)
|
||||
if not self.Window.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
|
||||
self.Window.RootNeedsDestroying = True
|
||||
else:
|
||||
|
@ -3132,6 +3135,7 @@ class Window:
|
|||
self.Window.QTApplication.exit() # kick the users out of the mainloop
|
||||
self.Window.QT_QMainWindow.close()
|
||||
self.Window.TKrootDestroyed = True
|
||||
self.Window.RootNeedsDestroying = True
|
||||
|
||||
# if self.CurrentlyRunningMainloop:
|
||||
# print("quitting window")
|
||||
|
@ -4248,7 +4252,6 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
|
|||
element.QT_QGraphicsScene = QGraphicsScene()
|
||||
element.QT_QGraphicsScene.setSceneRect(0,0,element.CanvasSize[0],element.CanvasSize[1])
|
||||
element.QT_QGraphicsView.setScene(element.QT_QGraphicsScene)
|
||||
element.QT_QGraphicsItemGroup = QGraphicsItemGroup()
|
||||
qt_row_layout.addWidget(element.QT_QGraphicsView)
|
||||
|
||||
# ------------------------- MENUBAR element ------------------------- #
|
||||
|
@ -5591,9 +5594,9 @@ def ObjToString(obj, extra=' '):
|
|||
|
||||
# ----------------------------------- The mighty Popup! ------------------------------------------------------------ #
|
||||
|
||||
def Popup(*args, button_color=None, background_color=None, text_color=None, button_type=POPUP_BUTTONS_OK,
|
||||
def Popup(*args, title=None, button_color=None, background_color=None, text_color=None, button_type=POPUP_BUTTONS_OK,
|
||||
auto_close=False, auto_close_duration=None, custom_text=(None, None), non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None,
|
||||
font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None), use_system_tray=False):
|
||||
font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
Popup - Display a popup box with as many parms as you wish to include
|
||||
:param args:
|
||||
|
@ -5615,8 +5618,6 @@ def Popup(*args, button_color=None, background_color=None, text_color=None, butt
|
|||
"""
|
||||
global _my_windows
|
||||
|
||||
# if use_system_tray:
|
||||
# QSystemTrayIcon.
|
||||
|
||||
if not args:
|
||||
args_to_print = ['']
|
||||
|
@ -5626,8 +5627,9 @@ def Popup(*args, button_color=None, background_color=None, text_color=None, butt
|
|||
local_line_width = line_width
|
||||
else:
|
||||
local_line_width = MESSAGE_BOX_LINE_WIDTH
|
||||
title = args_to_print[0] if args_to_print[0] is not None else 'None'
|
||||
window = Window(title, auto_size_text=True, background_color=background_color, button_color=button_color,
|
||||
|
||||
_title = title if title is not None else args_to_print[0]
|
||||
window = Window(_title, auto_size_text=True, background_color=background_color, button_color=button_color,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font,
|
||||
no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
|
||||
max_line_total, total_lines = 0, 0
|
||||
|
@ -5660,12 +5662,12 @@ def Popup(*args, button_color=None, background_color=None, text_color=None, butt
|
|||
# show either an OK or Yes/No depending on paramater
|
||||
if custom_text != (None, None):
|
||||
if type(custom_text) is not tuple:
|
||||
window.AddRow(PopupButton(custom_text, button_color=button_color, focus=True, bind_return_key=True))
|
||||
layout.append([PopupButton(custom_text, button_color=button_color, focus=True, bind_return_key=True)])
|
||||
elif custom_text[1] is None:
|
||||
window.AddRow(PopupButton(custom_text[0], button_color=button_color, focus=True, bind_return_key=True))
|
||||
layout.append([PopupButton(custom_text[0], button_color=button_color, focus=True, bind_return_key=True)])
|
||||
else:
|
||||
window.AddRow(PopupButton(custom_text[0], button_color=button_color, focus=True, bind_return_key=True),
|
||||
PopupButton(custom_text[1], button_color=button_color),Stretch())
|
||||
layout.append([PopupButton(custom_text[0], button_color=button_color, focus=True, bind_return_key=True),
|
||||
PopupButton(custom_text[1], button_color=button_color),Stretch()])
|
||||
elif button_type is POPUP_BUTTONS_YES_NO:
|
||||
layout.append([PopupButton('Yes', button_color=button_color, focus=True, bind_return_key=True, pad=((20, 5), 3),
|
||||
size=(60, 20)), PopupButton('No', button_color=button_color, size=(60, 20))])
|
||||
|
@ -5702,7 +5704,7 @@ def MsgBox(*args):
|
|||
|
||||
|
||||
# --------------------------- PopupNoButtons ---------------------------
|
||||
def PopupNoButtons(*args, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
def PopupNoButtons(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5723,7 +5725,7 @@ def PopupNoButtons(*args, button_color=None, background_color=None, text_color=N
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
button_type=POPUP_BUTTONS_NO_BUTTONS,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
|
||||
line_width=line_width,
|
||||
|
@ -5731,7 +5733,7 @@ def PopupNoButtons(*args, button_color=None, background_color=None, text_color=N
|
|||
|
||||
|
||||
# --------------------------- PopupNonBlocking ---------------------------
|
||||
def PopupNonBlocking(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
def PopupNonBlocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
auto_close=False, auto_close_duration=None, non_blocking=True, icon=DEFAULT_WINDOW_ICON,
|
||||
line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
|
||||
location=(None, None)):
|
||||
|
@ -5765,7 +5767,7 @@ PopupNoWait = PopupNonBlocking
|
|||
|
||||
|
||||
# --------------------------- PopupQuick - a NonBlocking, Self-closing Popup ---------------------------
|
||||
def PopupQuick(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
def PopupQuick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
auto_close=True, auto_close_duration=2, non_blocking=True, icon=DEFAULT_WINDOW_ICON, line_width=None,
|
||||
font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5787,7 +5789,7 @@ def PopupQuick(*args, button_type=POPUP_BUTTONS_OK, button_color=None, backgroun
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
button_type=button_type,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
|
||||
line_width=line_width,
|
||||
|
@ -5795,9 +5797,9 @@ def PopupQuick(*args, button_type=POPUP_BUTTONS_OK, button_color=None, backgroun
|
|||
|
||||
|
||||
# --------------------------- PopupQuick - a NonBlocking, Self-closing Popup with no titlebar and no buttons ---------------------------
|
||||
def PopupQuickMessage(*args, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=None, background_color=None,
|
||||
def PopupQuickMessage(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=None, background_color=None,
|
||||
text_color=None,
|
||||
auto_close=True, auto_close_duration=4, non_blocking=True, icon=DEFAULT_WINDOW_ICON,
|
||||
auto_close=True, auto_close_duration=3, non_blocking=True, icon=DEFAULT_WINDOW_ICON,
|
||||
line_width=None,
|
||||
font=None, no_titlebar=True, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5819,7 +5821,7 @@ def PopupQuickMessage(*args, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
button_type=button_type,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
|
||||
line_width=line_width,
|
||||
|
@ -5827,7 +5829,7 @@ def PopupQuickMessage(*args, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=
|
|||
|
||||
|
||||
# --------------------------- PopupNoTitlebar ---------------------------
|
||||
def PopupNoTitlebar(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
def PopupNoTitlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
auto_close=False, auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON,
|
||||
line_width=None, font=None, grab_anywhere=True, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5848,7 +5850,7 @@ def PopupNoTitlebar(*args, button_type=POPUP_BUTTONS_OK, button_color=None, back
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
button_type=button_type,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
|
||||
line_width=line_width,
|
||||
|
@ -5861,7 +5863,7 @@ PopupAnnoying = PopupNoTitlebar
|
|||
|
||||
|
||||
# --------------------------- PopupAutoClose ---------------------------
|
||||
def PopupAutoClose(*args, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
def PopupAutoClose(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
|
||||
auto_close=True, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, non_blocking=False, icon=DEFAULT_WINDOW_ICON,
|
||||
line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
|
||||
location=(None, None)):
|
||||
|
@ -5884,7 +5886,7 @@ def PopupAutoClose(*args, button_type=POPUP_BUTTONS_OK, button_color=None, backg
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_color=button_color, background_color=background_color, text_color=text_color,
|
||||
button_type=button_type,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
|
||||
line_width=line_width,
|
||||
|
@ -5895,7 +5897,7 @@ PopupTimed = PopupAutoClose
|
|||
|
||||
|
||||
# --------------------------- PopupError ---------------------------
|
||||
def PopupError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, background_color=None, text_color=None, auto_close=False,
|
||||
def PopupError(*args, title=None, button_color=DEFAULT_ERROR_BUTTON_COLOR, background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5916,14 +5918,14 @@ def PopupError(*args, button_color=DEFAULT_ERROR_BUTTON_COLOR, background_color=
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_type=POPUP_BUTTONS_ERROR, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_type=POPUP_BUTTONS_ERROR, background_color=background_color, text_color=text_color,
|
||||
non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
|
||||
auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
|
||||
keep_on_top=keep_on_top, location=location)
|
||||
|
||||
|
||||
# --------------------------- PopupCancel ---------------------------
|
||||
def PopupCancel(*args, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
def PopupCancel(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5944,14 +5946,14 @@ def PopupCancel(*args, button_color=None, background_color=None, text_color=None
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_type=POPUP_BUTTONS_CANCELLED, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_type=POPUP_BUTTONS_CANCELLED, background_color=background_color, text_color=text_color,
|
||||
non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
|
||||
auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
|
||||
keep_on_top=keep_on_top, location=location)
|
||||
|
||||
|
||||
# --------------------------- PopupOK ---------------------------
|
||||
def PopupOK(*args, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
def PopupOK(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -5972,14 +5974,14 @@ def PopupOK(*args, button_color=None, background_color=None, text_color=None, au
|
|||
:param location:
|
||||
:return:
|
||||
"""
|
||||
Popup(*args, button_type=POPUP_BUTTONS_OK, background_color=background_color, text_color=text_color,
|
||||
Popup(*args, title=title, button_type=POPUP_BUTTONS_OK, background_color=background_color, text_color=text_color,
|
||||
non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
|
||||
auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
|
||||
keep_on_top=keep_on_top, location=location)
|
||||
|
||||
|
||||
# --------------------------- PopupOKCancel ---------------------------
|
||||
def PopupOKCancel(*args, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
def PopupOKCancel(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -6000,14 +6002,14 @@ def PopupOKCancel(*args, button_color=None, background_color=None, text_color=No
|
|||
:param location:
|
||||
:return: OK, Cancel or None
|
||||
"""
|
||||
return Popup(*args, button_type=POPUP_BUTTONS_OK_CANCEL, background_color=background_color, text_color=text_color,
|
||||
return Popup(*args, title=title, button_type=POPUP_BUTTONS_OK_CANCEL, background_color=background_color, text_color=text_color,
|
||||
non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar,
|
||||
grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
|
||||
|
||||
|
||||
# --------------------------- PopupYesNo ---------------------------
|
||||
def PopupYesNo(*args, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
def PopupYesNo(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
|
||||
auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
|
||||
no_titlebar=False, grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -6028,7 +6030,7 @@ def PopupYesNo(*args, button_color=None, background_color=None, text_color=None,
|
|||
:param location:
|
||||
:return: Yes, No or None
|
||||
"""
|
||||
return Popup(*args, button_type=POPUP_BUTTONS_YES_NO, background_color=background_color, text_color=text_color,
|
||||
return Popup(*args, title=title, button_type=POPUP_BUTTONS_YES_NO, background_color=background_color, text_color=text_color,
|
||||
non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color,
|
||||
auto_close=auto_close, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar,
|
||||
grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
|
||||
|
@ -6041,7 +6043,7 @@ def PopupYesNo(*args, button_color=None, background_color=None, text_color=None,
|
|||
# --------------------------- PopupGetFolder ---------------------------
|
||||
|
||||
|
||||
def PopupGetFolder(message, default_path='', no_window=False, size=(None, None), button_color=None,
|
||||
def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
|
||||
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
|
||||
grab_anywhere=False, keep_on_top=False, location=(None, None), initial_folder=None):
|
||||
"""
|
||||
|
@ -6074,7 +6076,8 @@ def PopupGetFolder(message, default_path='', no_window=False, size=(None, None),
|
|||
[InputText(default_text=default_path, size=size), FolderBrowse(initial_folder=initial_folder)],
|
||||
[CloseButton('Ok', size=(60, 20), bind_return_key=True), CloseButton('Cancel', size=(60, 20))]]
|
||||
|
||||
window = Window(title=message, icon=icon, auto_size_text=True, button_color=button_color,
|
||||
_title = title if title is not None else message
|
||||
window = Window(title=_title, icon=icon, auto_size_text=True, button_color=button_color,
|
||||
background_color=background_color,
|
||||
font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
|
||||
location=location)
|
||||
|
@ -6090,7 +6093,7 @@ def PopupGetFolder(message, default_path='', no_window=False, size=(None, None),
|
|||
|
||||
# --------------------------- PopupGetFile ---------------------------
|
||||
|
||||
def PopupGetFile(message, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*.*"),),
|
||||
def PopupGetFile(message, title=None, default_path='', default_extension='', save_as=False, file_types=(("ALL Files", "*.*"),),
|
||||
no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
|
||||
icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
|
||||
location=(None, None), initial_folder=None):
|
||||
|
@ -6133,7 +6136,9 @@ def PopupGetFile(message, default_path='', default_extension='', save_as=False,
|
|||
[InputText(default_text=default_path, size=size), browse_button],
|
||||
[CButton('Ok', size=(60, 20), bind_return_key=True), CButton('Cancel', size=(60, 20))]]
|
||||
|
||||
window = Window(title=message, icon=icon, auto_size_text=True, button_color=button_color, font=font,
|
||||
_title = title if title is not None else message
|
||||
|
||||
window = Window(title=_title, icon=icon, auto_size_text=True, button_color=button_color, font=font,
|
||||
background_color=background_color,
|
||||
no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
|
||||
|
||||
|
@ -6148,7 +6153,7 @@ def PopupGetFile(message, default_path='', default_extension='', save_as=False,
|
|||
|
||||
# --------------------------- PopupGetText ---------------------------
|
||||
|
||||
def PopupGetText(message, default_text='', password_char='', size=(None, None), button_color=None,
|
||||
def PopupGetText(message, title=None, default_text='', password_char='', size=(None, None), button_color=None,
|
||||
background_color=None, text_color=None, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False,
|
||||
grab_anywhere=False, keep_on_top=False, location=(None, None)):
|
||||
"""
|
||||
|
@ -6173,7 +6178,9 @@ def PopupGetText(message, default_text='', password_char='', size=(None, None),
|
|||
[InputText(default_text=default_text, size=size, password_char=password_char)],
|
||||
[CloseButton('Ok', size=(60, 20), bind_return_key=True), CloseButton('Cancel', size=(60, 20))]]
|
||||
|
||||
window = Window(title=message, icon=icon, auto_size_text=True, button_color=button_color, no_titlebar=no_titlebar,
|
||||
_title = title if title is not None else message
|
||||
|
||||
window = Window(title=_title, icon=icon, auto_size_text=True, button_color=button_color, no_titlebar=no_titlebar,
|
||||
background_color=background_color, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
|
||||
location=location)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png)
|
||||
|
||||
[![Downloads](http://pepy.tech/badge/pysimpleguiqt)](http://pepy.tech/project/pysimplegui)
|
||||
|
@ -22,15 +23,15 @@
|
|||
|
||||
# PySimpleGUIQt
|
||||
|
||||
"Qt without the ugly"
|
||||
|
||||
## The Alpha Release
|
||||
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
## The Alpha Release Version 0.12.0
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
|
||||
|
||||
|
||||
-----
|
||||
## Getting Started with PySimpleGUIQt
|
||||
----- ## Getting Started with PySimpleGUIQt
|
||||
|
||||
Welcome to the Alpha Release of PySimpleGUI for Qt!
|
||||
|
||||
|
@ -62,33 +63,22 @@ Fonts should be in the format (font family, size). You can use the older string
|
|||
### Installing PySimpleGUIQt for Python 3
|
||||
|
||||
pip install --upgrade PySimpleGUIQt
|
||||
On Linux systems you need to run pip3.
|
||||
|
||||
On Linux systems you need to run pip3.
|
||||
|
||||
pip3 install --upgrade PySimpleGUIQt
|
||||
|
||||
|
||||
pip3 install --upgrade PySimpleGUIQt
|
||||
### Installing PySide2 or PyQt5 for Python 3
|
||||
|
||||
It is recommended that you use PySide2, however, if that cannot be found, then PyQt5 will be attempted. To install either of these:
|
||||
|
||||
```pip install PySide2```
|
||||
|
||||
or
|
||||
or
|
||||
|
||||
```pip install PyQt5```
|
||||
|
||||
|
||||
## Testing your installation
|
||||
|
||||
Once you have installed, or copied the .py file to your app folder, you can test the installation using python. At the command prompt start up Python.
|
||||
```
|
||||
python3
|
||||
>>> import PySimpleGUIQt
|
||||
>>> PySimpleGUIQt.main()
|
||||
```
|
||||
|
||||
You will see a sample window in the center of your screen. If it's not installed correctly you are likely to get an error message during one of those commands
|
||||
## Testing your installation
|
||||
Once you have installed, or copied the .py file to your app folder, you can test the installation using python. At the command prompt start up Python.
|
||||
``` python3 >>> import PySimpleGUIQt >>> PySimpleGUIQt.main() ```
|
||||
You will see a sample window in the center of your screen. If it's not installed correctly you are likely to get an error message during one of those commands
|
||||
|
||||
Here is the window you should see:
|
||||
|
||||
|
@ -96,23 +86,19 @@ Here is the window you should see:
|
|||
|
||||
|
||||
|
||||
## Prerequisites
|
||||
Python 3
|
||||
## Prerequisites Python 3
|
||||
PySide2 or PyQt5
|
||||
|
||||
|
||||
|
||||
## Using - Python 3
|
||||
|
||||
To use in your code, simply import....
|
||||
To use in your code, simply import....
|
||||
`import PySimpleGUIQt as sg`
|
||||
|
||||
Then use the exact same code as any other PySimpleGUI program that runs on tkinter.
|
||||
Then use the exact same code as any other PySimpleGUI program that runs on tkinter.
|
||||
|
||||
## Status
|
||||
|
||||
### FEATURE COMPLETE!
|
||||
|
||||
All of the major features are DONE. They may not have all of their options working, but they can be added to your windows. It's been an amazing week to get here.
|
||||
|
||||
I hope you enjoy this ALPHA release! Please post a screenshot on the GitHub site. There is an Issue where users have been posting their applications. It's a place for you to show-off and a place for others to learn from your designs. Your window does not have to be complex.... all GUIs, no matter how simple, are something we can learn from.
|
||||
|
@ -144,10 +130,10 @@ These Elements are "complete" (a relative term... more are more complete than ot
|
|||
* Timeouts for Read calls
|
||||
* Change Submits parametes for most Elements
|
||||
* Table
|
||||
* Basic display
|
||||
* Read selected rows
|
||||
* change_submits events
|
||||
* Updates
|
||||
* Basic display
|
||||
* Read selected rows
|
||||
* change_submits events
|
||||
* Updates
|
||||
* Image as a background (new feature)
|
||||
* Graph - Draw line, draw circle, draw text
|
||||
* Image Element
|
||||
|
@ -161,20 +147,27 @@ These Elements are "complete" (a relative term... more are more complete than ot
|
|||
|
||||
Notable MISSING features at the moment include:
|
||||
* Graphs Element Methods - erasing, draw arc, etc
|
||||
* Change submits - for radio buttons
|
||||
|
||||
## Release Notes:
|
||||
|
||||
### 0.12.0 - 20-Nov-2018
|
||||
Correctly restore stdout when OutputElement is deleted
|
||||
Added Finalize ability
|
||||
**Better multiwindow handling... maybe it's finally fixed!**
|
||||
Radio button default value
|
||||
Dial element default value
|
||||
Show expanded option for trees
|
||||
Titles for popups
|
||||
|
||||
|
||||
|
||||
## Design
|
||||
|
||||
## Author
|
||||
MikeTheWatchGuy
|
||||
## Author
|
||||
Mike B.
|
||||
|
||||
## Demo Code Contributors
|
||||
|
||||
|
||||
## License
|
||||
|
||||
GNU Lesser General Public License (LGPL 3) +
|
||||
## License
|
||||
GNU Lesser General Public License (LGPL 3) +
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
|
|
Loading…
Reference in New Issue