Merge pull request #750 from MikeTheWatchGuy/Dev-latest

0.12.0, restructure folders, multi-window design patterns
This commit is contained in:
MikeTheWatchGuy 2018-11-20 12:43:54 -05:00 committed by GitHub
commit 39ffd75422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 342 additions and 214 deletions

View File

@ -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()

View File

@ -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

View File

@ -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()

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -487,7 +487,8 @@ class InputText(Element):
self.DefaultText = value self.DefaultText = value
def Get(self): def Get(self):
return self.TKStringVar.get() return self.QT_QLineEdit.text()
# return self.TKStringVar.get()
def SetFocus(self): def SetFocus(self):
try: try:
@ -1160,6 +1161,8 @@ class Output(Element):
# self.my_stdout.write(str(m)) # self.my_stdout.write(str(m))
def __del__(self): def __del__(self):
sys.stdout = self.my_stdout
sys.stderr = self.my_stderr
super().__del__() super().__del__()
@ -3042,7 +3045,7 @@ class Window:
:return: :return:
''' '''
self._AlphaChannel = alpha self._AlphaChannel = alpha
if self._AlphaChannel: if self._AlphaChannel is not None:
self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel) self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel)
@property @property
@ -3052,7 +3055,7 @@ class Window:
@AlphaChannel.setter @AlphaChannel.setter
def AlphaChannel(self, alpha): def AlphaChannel(self, alpha):
self._AlphaChannel = alpha self._AlphaChannel = alpha
if self._AlphaChannel: if self._AlphaChannel is not None:
self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel) self.QT_QMainWindow.setWindowOpacity(self._AlphaChannel)
def BringToFront(self): def BringToFront(self):
@ -3124,7 +3127,7 @@ class Window:
return QWidget.eventFilter(self, widget, event) return QWidget.eventFilter(self, widget, event)
def closeEvent(self, 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! if not self.Window.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
self.Window.RootNeedsDestroying = True self.Window.RootNeedsDestroying = True
else: else:
@ -3132,6 +3135,7 @@ class Window:
self.Window.QTApplication.exit() # kick the users out of the mainloop self.Window.QTApplication.exit() # kick the users out of the mainloop
self.Window.QT_QMainWindow.close() self.Window.QT_QMainWindow.close()
self.Window.TKrootDestroyed = True self.Window.TKrootDestroyed = True
self.Window.RootNeedsDestroying = True
# if self.CurrentlyRunningMainloop: # if self.CurrentlyRunningMainloop:
# print("quitting window") # print("quitting window")
@ -4248,7 +4252,6 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
element.QT_QGraphicsScene = QGraphicsScene() element.QT_QGraphicsScene = QGraphicsScene()
element.QT_QGraphicsScene.setSceneRect(0,0,element.CanvasSize[0],element.CanvasSize[1]) element.QT_QGraphicsScene.setSceneRect(0,0,element.CanvasSize[0],element.CanvasSize[1])
element.QT_QGraphicsView.setScene(element.QT_QGraphicsScene) element.QT_QGraphicsView.setScene(element.QT_QGraphicsScene)
element.QT_QGraphicsItemGroup = QGraphicsItemGroup()
qt_row_layout.addWidget(element.QT_QGraphicsView) qt_row_layout.addWidget(element.QT_QGraphicsView)
# ------------------------- MENUBAR element ------------------------- # # ------------------------- MENUBAR element ------------------------- #
@ -5591,9 +5594,9 @@ def ObjToString(obj, extra=' '):
# ----------------------------------- The mighty Popup! ------------------------------------------------------------ # # ----------------------------------- 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, 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 Popup - Display a popup box with as many parms as you wish to include
:param args: :param args:
@ -5615,8 +5618,6 @@ def Popup(*args, button_color=None, background_color=None, text_color=None, butt
""" """
global _my_windows global _my_windows
# if use_system_tray:
# QSystemTrayIcon.
if not args: if not args:
args_to_print = [''] 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 local_line_width = line_width
else: else:
local_line_width = MESSAGE_BOX_LINE_WIDTH 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, 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) no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
max_line_total, total_lines = 0, 0 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 # show either an OK or Yes/No depending on paramater
if custom_text != (None, None): if custom_text != (None, None):
if type(custom_text) is not tuple: 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: 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: else:
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),
PopupButton(custom_text[1], button_color=button_color),Stretch()) PopupButton(custom_text[1], button_color=button_color),Stretch()])
elif button_type is POPUP_BUTTONS_YES_NO: 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), 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))]) size=(60, 20)), PopupButton('No', button_color=button_color, size=(60, 20))])
@ -5702,7 +5704,7 @@ def MsgBox(*args):
# --------------------------- PopupNoButtons --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: :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, button_type=POPUP_BUTTONS_NO_BUTTONS,
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon, auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
line_width=line_width, line_width=line_width,
@ -5731,7 +5733,7 @@ def PopupNoButtons(*args, button_color=None, background_color=None, text_color=N
# --------------------------- PopupNonBlocking --------------------------- # --------------------------- 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, 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, line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
location=(None, None)): location=(None, None)):
@ -5765,7 +5767,7 @@ PopupNoWait = PopupNonBlocking
# --------------------------- PopupQuick - a NonBlocking, Self-closing Popup --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: :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, button_type=button_type,
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon, auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
line_width=line_width, 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 --------------------------- # --------------------------- 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, 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, line_width=None,
font=None, no_titlebar=True, grab_anywhere=False, keep_on_top=False, location=(None, 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: :param location:
:return: :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, button_type=button_type,
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon, auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
line_width=line_width, line_width=line_width,
@ -5827,7 +5829,7 @@ def PopupQuickMessage(*args, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=
# --------------------------- PopupNoTitlebar --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: :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, button_type=button_type,
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon, auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
line_width=line_width, line_width=line_width,
@ -5861,7 +5863,7 @@ PopupAnnoying = PopupNoTitlebar
# --------------------------- PopupAutoClose --------------------------- # --------------------------- 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, 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, line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
location=(None, None)): location=(None, None)):
@ -5884,7 +5886,7 @@ def PopupAutoClose(*args, button_type=POPUP_BUTTONS_OK, button_color=None, backg
:param location: :param location:
:return: :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, button_type=button_type,
auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon, auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
line_width=line_width, line_width=line_width,
@ -5895,7 +5897,7 @@ PopupTimed = PopupAutoClose
# --------------------------- PopupError --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: :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, 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, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
keep_on_top=keep_on_top, location=location) keep_on_top=keep_on_top, location=location)
# --------------------------- PopupCancel --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: :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, 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, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
keep_on_top=keep_on_top, location=location) keep_on_top=keep_on_top, location=location)
# --------------------------- PopupOK --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: :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, 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, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
keep_on_top=keep_on_top, location=location) keep_on_top=keep_on_top, location=location)
# --------------------------- PopupOKCancel --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: OK, Cancel or None :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, 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, 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) grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location)
# --------------------------- PopupYesNo --------------------------- # --------------------------- 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, 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)): 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: :param location:
:return: Yes, No or None :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, 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, 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) 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 --------------------------- # --------------------------- 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, 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): 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)], [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))]] [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, background_color=background_color,
font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
location=location) location=location)
@ -6090,7 +6093,7 @@ def PopupGetFolder(message, default_path='', no_window=False, size=(None, None),
# --------------------------- PopupGetFile --------------------------- # --------------------------- 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, 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, icon=DEFAULT_WINDOW_ICON, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=False,
location=(None, None), initial_folder=None): 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], [InputText(default_text=default_path, size=size), browse_button],
[CButton('Ok', size=(60, 20), bind_return_key=True), CButton('Cancel', size=(60, 20))]] [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, background_color=background_color,
no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location) 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 --------------------------- # --------------------------- 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, 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)): 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)], [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))]] [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, background_color=background_color, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
location=location) location=location)

View File

@ -6,6 +6,7 @@
![pysimplegui_logo](https://user-images.githubusercontent.com/13696193/43165867-fe02e3b2-8f62-11e8-9fd0-cc7c86b11772.png) ![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) [![Downloads](http://pepy.tech/badge/pysimpleguiqt)](http://pepy.tech/project/pysimplegui)
@ -22,15 +23,15 @@
# PySimpleGUIQt # 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! 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 ### Installing PySimpleGUIQt for Python 3
pip install --upgrade PySimpleGUIQt 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 ### 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: 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``` ```pip install PySide2```
or
or
```pip install PyQt5``` ```pip install PyQt5```
## Testing your installation
## 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() ```
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. 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
```
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: Here is the window you should see:
@ -96,23 +86,19 @@ Here is the window you should see:
## Prerequisites ## Prerequisites Python 3
Python 3
PySide2 or PyQt5 PySide2 or PyQt5
## Using - Python 3 ## Using - Python 3
To use in your code, simply import....
To use in your code, simply import....
`import PySimpleGUIQt as sg` `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 ## Status
### FEATURE COMPLETE! ### 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. 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. 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 * Timeouts for Read calls
* Change Submits parametes for most Elements * Change Submits parametes for most Elements
* Table * Table
* Basic display * Basic display
* Read selected rows * Read selected rows
* change_submits events * change_submits events
* Updates * Updates
* Image as a background (new feature) * Image as a background (new feature)
* Graph - Draw line, draw circle, draw text * Graph - Draw line, draw circle, draw text
* Image Element * 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: Notable MISSING features at the moment include:
* Graphs Element Methods - erasing, draw arc, etc * 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 ## Design
## Author
## Author Mike B.
MikeTheWatchGuy
## Demo Code Contributors ## Demo Code Contributors
## License
## License GNU Lesser General Public License (LGPL 3) +
GNU Lesser General Public License (LGPL 3) +
## Acknowledgments ## Acknowledgments