mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
progress on scrollable frame
This commit is contained in:
@@ -64,6 +64,9 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
self._iconify_called_before_window_exists = False # indicates if iconify() was called before window is first shown through update() or mainloop()
|
||||
self._block_update_dimensions_event = False
|
||||
|
||||
# save focus before calling withdraw
|
||||
self.focused_widget_before_widthdraw = None
|
||||
|
||||
# set CustomTkinter titlebar icon (Windows only)
|
||||
if sys.platform.startswith("win"):
|
||||
self.after(200, self._windows_set_titlebar_icon)
|
||||
@@ -137,24 +140,26 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
|
||||
def update(self):
|
||||
if self._window_exists is False:
|
||||
self._window_exists = True
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if not self._withdraw_called_before_window_exists and not self._iconify_called_before_window_exists:
|
||||
# print("window dont exists -> deiconify in update")
|
||||
self.deiconify()
|
||||
|
||||
self._window_exists = True
|
||||
|
||||
super().update()
|
||||
|
||||
def mainloop(self, *args, **kwargs):
|
||||
if not self._window_exists:
|
||||
self._window_exists = True
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
self._windows_set_titlebar_color(self._get_appearance_mode())
|
||||
|
||||
if not self._withdraw_called_before_window_exists and not self._iconify_called_before_window_exists:
|
||||
# print("window dont exists -> deiconify in mainloop")
|
||||
self.deiconify()
|
||||
|
||||
self._window_exists = True
|
||||
|
||||
super().mainloop(*args, **kwargs)
|
||||
|
||||
def resizable(self, width: bool = None, height: bool = None):
|
||||
@@ -267,9 +272,11 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
# print("window_exists -> state_before_windows_set_titlebar_color: ", self.state_before_windows_set_titlebar_color)
|
||||
|
||||
if self._state_before_windows_set_titlebar_color != "iconic" or self._state_before_windows_set_titlebar_color != "withdrawn":
|
||||
self.focused_widget_before_widthdraw = self.focus_get()
|
||||
super().withdraw() # hide window so that it can be redrawn after the titlebar change so that the color change is visible
|
||||
else:
|
||||
# print("window dont exists -> withdraw and update")
|
||||
self.focused_widget_before_widthdraw = self.focus_get()
|
||||
super().withdraw()
|
||||
super().update()
|
||||
|
||||
@@ -298,7 +305,7 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
except Exception as err:
|
||||
print(err)
|
||||
|
||||
if self._window_exists:
|
||||
if self._window_exists or True:
|
||||
# print("window_exists -> return to original state: ", self.state_before_windows_set_titlebar_color)
|
||||
if self._state_before_windows_set_titlebar_color == "normal":
|
||||
self.deiconify()
|
||||
@@ -311,6 +318,10 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
else:
|
||||
pass # wait for update or mainloop to be called
|
||||
|
||||
if self.focused_widget_before_widthdraw is not None:
|
||||
self.after(1, self.focused_widget_before_widthdraw.focus)
|
||||
self.focused_widget_before_widthdraw = None
|
||||
|
||||
def _set_appearance_mode(self, mode_string: str):
|
||||
super()._set_appearance_mode(mode_string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user