Permalink
Browse files

Release 3.14.1, 1.14.1 + new window feature disable_close

  • Loading branch information...
MikeTheWatchGuy committed Nov 3, 2018
1 parent d343308 commit be1aa4f00a40947f3ea1ca3bdbcf7f65a0f75230
Showing with 25 additions and 25 deletions.
  1. +7 −4 PySimpleGUI.py
  2. +18 −21 PySimpleGUI27.py
@@ -2702,7 +2702,7 @@ def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_but
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel=False,
alpha_channel=1, return_keyboard_events=False, use_default_focus=True, text_justification=None,
no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=False):
no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=False, disable_close=False):
'''
Window
:param title:
@@ -2774,6 +2774,7 @@ def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_but
self.Timeout = None
self.TimeoutKey = '_timeout_'
self.TimerCancelled = False
self.DisableClose = disable_close
# ------------------------- Add ONE Row to Form ------------------------- #
def AddRow(self, *args):
@@ -3123,6 +3124,8 @@ def Close(self):
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
def OnClosingCallback(self):
if self.DisableClose:
return
# print('Got closing callback')
self.TKroot.quit() # kick the users out of the mainloop
if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
@@ -4679,9 +4682,9 @@ def StartupTK(my_flex_form):
# hidden window
_my_windows.Increment()
_my_windows.hidden_master_root = tk.Tk()
_my_windows.hidden_master_root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
_my_windows.hidden_master_root.wm_overrideredirect(True)
_my_windows.hidden_master_root.withdraw()
_my_windows.hidden_master_root.attributes('-alpha', 0) # HIDE this window really really really good
_my_windows.hidden_master_root.wm_overrideredirect(True) # damn, what did this do again?
_my_windows.hidden_master_root.withdraw() # no, REALLY hide it
# root = tk.Tk() # users windows are no longer using tk.Tk. They are all Toplevel windows
root = tk.Toplevel()
else:
@@ -1224,10 +1224,7 @@ def __del__(self):
# ---------------------------------------------------------------------- #
class Button(Element):
def __init__(self, button_text='', button_type=BUTTON_TYPE_READ_FORM, target=(None, None), tooltip=None,
file_types=(("ALL Files", "*.*"),), initial_folder=None, disabled=False, image_filename=None,
image_data=None, image_size=(None, None), image_subsample=None, border_width=None, size=(None, None),
auto_size_button=None, button_color=None, font=None, bind_return_key=False,
focus=False, pad=None, key=None):
file_types=(("ALL Files", "*.*"),), initial_folder=None, disabled=False, change_submits=False, image_filename=None, image_data=None, image_size=(None, None), image_subsample=None, border_width=None, size=(None, None), auto_size_button=None, button_color=None, font=None, bind_return_key=False, focus=False, pad=None, key=None):
'''
Button Element
:param button_text:
@@ -1271,6 +1268,7 @@ def __init__(self, button_text='', button_type=BUTTON_TYPE_READ_FORM, target=(No
self.DefaultDate_M_D_Y = (None, None, None)
self.InitialFolder = initial_folder
self.Disabled = disabled
self.ChangeSubmits = change_submits
super().__init__(ELEM_TYPE_BUTTON, size=size, font=font, pad=pad, key=key, tooltip=tooltip)
return
@@ -1530,7 +1528,7 @@ def __init__(self, filename=None, data=None, background_color=None, size=(None,
tooltip=tooltip)
return
def Update(self, filename=None, data=None):
def Update(self, filename=None, data=None, size=(None,None)):
if filename is not None:
image = tk.PhotoImage(file=filename)
elif data is not None:
@@ -1543,9 +1541,8 @@ def Update(self, filename=None, data=None):
# image = data
else:
return
width, height = image.width(), image.height()
width, height = size[0] or image.width(), size[1] or image.height()
self.tktext_label.configure(image=image, width=width, height=height)
# self.tktext_label.configure(image=image)
self.tktext_label.image = image
def __del__(self):
@@ -3223,46 +3220,45 @@ def __del__(self):
# ------------------------- FOLDER BROWSE Element lazy function ------------------------- #
def FolderBrowse(button_text='Browse', target=(ThisRow, -1), initial_folder=None, tooltip=None, size=(None, None),
auto_size_button=None, button_color=None, disabled=False, font=None, pad=None, key=None):
auto_size_button=None, button_color=None, disabled=False, change_submits=False, font=None, pad=None, key=None):
return Button(button_text=button_text, button_type=BUTTON_TYPE_BROWSE_FOLDER, target=target,
initial_folder=initial_folder, tooltip=tooltip, size=size, auto_size_button=auto_size_button,
disabled=disabled, button_color=button_color, font=font, pad=pad, key=key)
disabled=disabled, button_color=button_color,change_submits=change_submits, font=font, pad=pad, key=key)
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
def FileBrowse(button_text='Browse', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), initial_folder=None,
tooltip=None, size=(None, None), auto_size_button=None, button_color=None, font=None, disabled=False,
tooltip=None, size=(None, None), auto_size_button=None, button_color=None, change_submits=False, font=None, disabled=False,
pad=None, key=None):
return Button(button_text=button_text, button_type=BUTTON_TYPE_BROWSE_FILE, target=target, file_types=file_types,
initial_folder=initial_folder, tooltip=tooltip, size=size, auto_size_button=auto_size_button,
disabled=disabled, button_color=button_color, font=font, pad=pad, key=key)
initial_folder=initial_folder, tooltip=tooltip, size=size, auto_size_button=auto_size_button, change_submits=change_submits, disabled=disabled, button_color=button_color, font=font, pad=pad, key=key)
# ------------------------- FILES BROWSE Element (Multiple file selection) lazy function ------------------------- #
def FilesBrowse(button_text='Browse', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), disabled=False,
initial_folder=None, tooltip=None, size=(None, None), auto_size_button=None, button_color=None,
initial_folder=None, tooltip=None, size=(None, None), auto_size_button=None, button_color=None, change_submits=False,
font=None, pad=None, key=None):
return Button(button_text=button_text, button_type=BUTTON_TYPE_BROWSE_FILES, target=target, file_types=file_types,
initial_folder=initial_folder, tooltip=tooltip, size=size, auto_size_button=auto_size_button,
initial_folder=initial_folder,change_submits=change_submits, tooltip=tooltip, size=size, auto_size_button=auto_size_button,
disabled=disabled, button_color=button_color, font=font, pad=pad, key=key)
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
def FileSaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), initial_folder=None,
disabled=False, tooltip=None, size=(None, None), auto_size_button=None, button_color=None, font=None,
disabled=False, tooltip=None, size=(None, None), auto_size_button=None, button_color=None, change_submits=False, font=None,
pad=None, key=None):
return Button(button_text=button_text, button_type=BUTTON_TYPE_SAVEAS_FILE, target=target, file_types=file_types,
initial_folder=initial_folder, tooltip=tooltip, size=size, disabled=disabled,
auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
auto_size_button=auto_size_button, button_color=button_color, change_submits=change_submits, font=font, pad=pad, key=key)
# ------------------------- SAVE AS Element lazy function ------------------------- #
def SaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), initial_folder=None,
disabled=False, tooltip=None, size=(None, None), auto_size_button=None, button_color=None, font=None,
disabled=False, tooltip=None, size=(None, None), auto_size_button=None, button_color=None, change_submits=False, font=None,
pad=None, key=None):
return Button(button_text=button_text, button_type=BUTTON_TYPE_SAVEAS_FILE, target=target, file_types=file_types,
initial_folder=initial_folder, tooltip=tooltip, size=size, disabled=disabled,
auto_size_button=auto_size_button, button_color=button_color, font=font, pad=pad, key=key)
auto_size_button=auto_size_button, button_color=button_color, change_submits=change_submits, font=font, pad=pad, key=key)
# ------------------------- SAVE BUTTON Element lazy function ------------------------- #
@@ -4697,7 +4693,7 @@ def StartupTK(my_flex_form):
_my_windows.hidden_master_root = tk.Tk()
_my_windows.hidden_master_root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
_my_windows.hidden_master_root.wm_overrideredirect(True)
_my_windows.hidden_master_root.withdraw()
# root = tk.Tk() # users windows are no longer using tk.Tk. They are all Toplevel windows
root = tk.Toplevel()
else:
@@ -6663,8 +6659,9 @@ def main():
[Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()],
[Ok(), Cancel()]]
button, values = Window('Demo window..').Layout(layout).Read()
window = Window('Demo window..').Layout(layout)
event, values = window.Read()
window.Close()
if __name__ == '__main__':
main()

0 comments on commit be1aa4f

Please sign in to comment.