Release 3.14.1, 1.14.1 + new window feature disable_close
This commit is contained in:
parent
d34330891c
commit
be1aa4f00a
|
@ -2702,7 +2702,7 @@ class Window:
|
||||||
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
|
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,
|
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,
|
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
|
Window
|
||||||
:param title:
|
:param title:
|
||||||
|
@ -2774,6 +2774,7 @@ class Window:
|
||||||
self.Timeout = None
|
self.Timeout = None
|
||||||
self.TimeoutKey = '_timeout_'
|
self.TimeoutKey = '_timeout_'
|
||||||
self.TimerCancelled = False
|
self.TimerCancelled = False
|
||||||
|
self.DisableClose = disable_close
|
||||||
|
|
||||||
# ------------------------- Add ONE Row to Form ------------------------- #
|
# ------------------------- Add ONE Row to Form ------------------------- #
|
||||||
def AddRow(self, *args):
|
def AddRow(self, *args):
|
||||||
|
@ -3123,6 +3124,8 @@ class Window:
|
||||||
|
|
||||||
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
|
# IT FINALLY WORKED! 29-Oct-2018 was the first time this damned thing got called
|
||||||
def OnClosingCallback(self):
|
def OnClosingCallback(self):
|
||||||
|
if self.DisableClose:
|
||||||
|
return
|
||||||
# print('Got closing callback')
|
# print('Got closing callback')
|
||||||
self.TKroot.quit() # kick the users out of the mainloop
|
self.TKroot.quit() # kick the users out of the mainloop
|
||||||
if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
|
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
|
# hidden window
|
||||||
_my_windows.Increment()
|
_my_windows.Increment()
|
||||||
_my_windows.hidden_master_root = tk.Tk()
|
_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.attributes('-alpha', 0) # HIDE this window really really really good
|
||||||
_my_windows.hidden_master_root.wm_overrideredirect(True)
|
_my_windows.hidden_master_root.wm_overrideredirect(True) # damn, what did this do again?
|
||||||
_my_windows.hidden_master_root.withdraw()
|
_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.Tk() # users windows are no longer using tk.Tk. They are all Toplevel windows
|
||||||
root = tk.Toplevel()
|
root = tk.Toplevel()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1224,10 +1224,7 @@ class Output(Element):
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Button(Element):
|
class Button(Element):
|
||||||
def __init__(self, button_text='', button_type=BUTTON_TYPE_READ_FORM, target=(None, None), tooltip=None,
|
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,
|
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):
|
||||||
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
|
Button Element
|
||||||
:param button_text:
|
:param button_text:
|
||||||
|
@ -1271,6 +1268,7 @@ class Button(Element):
|
||||||
self.DefaultDate_M_D_Y = (None, None, None)
|
self.DefaultDate_M_D_Y = (None, None, None)
|
||||||
self.InitialFolder = initial_folder
|
self.InitialFolder = initial_folder
|
||||||
self.Disabled = disabled
|
self.Disabled = disabled
|
||||||
|
self.ChangeSubmits = change_submits
|
||||||
|
|
||||||
super().__init__(ELEM_TYPE_BUTTON, size=size, font=font, pad=pad, key=key, tooltip=tooltip)
|
super().__init__(ELEM_TYPE_BUTTON, size=size, font=font, pad=pad, key=key, tooltip=tooltip)
|
||||||
return
|
return
|
||||||
|
@ -1530,7 +1528,7 @@ class Image(Element):
|
||||||
tooltip=tooltip)
|
tooltip=tooltip)
|
||||||
return
|
return
|
||||||
|
|
||||||
def Update(self, filename=None, data=None):
|
def Update(self, filename=None, data=None, size=(None,None)):
|
||||||
if filename is not None:
|
if filename is not None:
|
||||||
image = tk.PhotoImage(file=filename)
|
image = tk.PhotoImage(file=filename)
|
||||||
elif data is not None:
|
elif data is not None:
|
||||||
|
@ -1543,9 +1541,8 @@ class Image(Element):
|
||||||
# image = data
|
# image = data
|
||||||
else:
|
else:
|
||||||
return
|
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, width=width, height=height)
|
||||||
# self.tktext_label.configure(image=image)
|
|
||||||
self.tktext_label.image = image
|
self.tktext_label.image = image
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -3223,46 +3220,45 @@ FlexForm = Window
|
||||||
|
|
||||||
# ------------------------- FOLDER BROWSE Element lazy function ------------------------- #
|
# ------------------------- FOLDER BROWSE Element lazy function ------------------------- #
|
||||||
def FolderBrowse(button_text='Browse', target=(ThisRow, -1), initial_folder=None, tooltip=None, size=(None, None),
|
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,
|
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,
|
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 ------------------------- #
|
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
|
||||||
def FileBrowse(button_text='Browse', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), initial_folder=None,
|
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):
|
pad=None, key=None):
|
||||||
return Button(button_text=button_text, button_type=BUTTON_TYPE_BROWSE_FILE, target=target, file_types=file_types,
|
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,
|
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)
|
||||||
disabled=disabled, button_color=button_color, font=font, pad=pad, key=key)
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------- FILES BROWSE Element (Multiple file selection) lazy function ------------------------- #
|
# ------------------------- FILES BROWSE Element (Multiple file selection) lazy function ------------------------- #
|
||||||
def FilesBrowse(button_text='Browse', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), disabled=False,
|
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):
|
font=None, pad=None, key=None):
|
||||||
return Button(button_text=button_text, button_type=BUTTON_TYPE_BROWSE_FILES, target=target, file_types=file_types,
|
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)
|
disabled=disabled, button_color=button_color, font=font, pad=pad, key=key)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
|
# ------------------------- FILE BROWSE Element lazy function ------------------------- #
|
||||||
def FileSaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), initial_folder=None,
|
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):
|
pad=None, key=None):
|
||||||
return Button(button_text=button_text, button_type=BUTTON_TYPE_SAVEAS_FILE, target=target, file_types=file_types,
|
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,
|
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 ------------------------- #
|
# ------------------------- SAVE AS Element lazy function ------------------------- #
|
||||||
def SaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=(("ALL Files", "*.*"),), initial_folder=None,
|
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):
|
pad=None, key=None):
|
||||||
return Button(button_text=button_text, button_type=BUTTON_TYPE_SAVEAS_FILE, target=target, file_types=file_types,
|
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,
|
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 ------------------------- #
|
# ------------------------- 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 = tk.Tk()
|
||||||
_my_windows.hidden_master_root.attributes('-alpha', 0) # hide window while building it. makes for smoother 'paint'
|
_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.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.Tk() # users windows are no longer using tk.Tk. They are all Toplevel windows
|
||||||
root = tk.Toplevel()
|
root = tk.Toplevel()
|
||||||
else:
|
else:
|
||||||
|
@ -6663,8 +6659,9 @@ def main():
|
||||||
[Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()],
|
[Text('Destination Folder', size=(15, 1), justification='right'), InputText('Dest'), FolderBrowse()],
|
||||||
[Ok(), Cancel()]]
|
[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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue