mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
This commit is contained in:
@ -52,7 +52,8 @@ class CTk(tkinter.Tk):
|
||||
super().title("CTk")
|
||||
self.geometry(f"{self.current_width}x{self.current_height}")
|
||||
|
||||
self.window_exists = False # indicates if the window is already shown through update() or mainloop()
|
||||
self.state_before_windows_set_titlebar_color = None
|
||||
self.window_exists = False # indicates if the window is already shown through update() or mainloop() after init
|
||||
self.withdraw_called_before_window_exists = False # indicates if withdraw() was called before window is first shown through update() or mainloop()
|
||||
self.iconify_called_before_window_exists = False # indicates if iconify() was called before window is first shown through update() or mainloop()
|
||||
|
||||
@ -121,7 +122,9 @@ class CTk(tkinter.Tk):
|
||||
self.window_exists = True
|
||||
|
||||
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()
|
||||
|
||||
super().update()
|
||||
|
||||
def mainloop(self, *args, **kwargs):
|
||||
@ -129,7 +132,9 @@ class CTk(tkinter.Tk):
|
||||
self.window_exists = True
|
||||
|
||||
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()
|
||||
|
||||
super().mainloop(*args, **kwargs)
|
||||
|
||||
def resizable(self, *args, **kwargs):
|
||||
@ -279,8 +284,15 @@ class CTk(tkinter.Tk):
|
||||
|
||||
if sys.platform.startswith("win") and not Settings.deactivate_windows_window_header_manipulation:
|
||||
|
||||
super().withdraw() # hide window so that it can be redrawn after the titlebar change so that the color change is visible
|
||||
if not self.window_exists:
|
||||
if self.window_exists:
|
||||
self.state_before_windows_set_titlebar_color = self.state()
|
||||
# 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":
|
||||
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")
|
||||
super().withdraw()
|
||||
super().update()
|
||||
|
||||
if color_mode.lower() == "dark":
|
||||
@ -309,7 +321,17 @@ class CTk(tkinter.Tk):
|
||||
print(err)
|
||||
|
||||
if self.window_exists:
|
||||
self.deiconify()
|
||||
# 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()
|
||||
elif self.state_before_windows_set_titlebar_color == "iconic":
|
||||
self.iconify()
|
||||
elif self.state_before_windows_set_titlebar_color == "zoomed":
|
||||
self.state("zoomed")
|
||||
else:
|
||||
self.state(self.state_before_windows_set_titlebar_color) # other states
|
||||
else:
|
||||
pass # wait for update or mainloop to be called
|
||||
|
||||
def set_appearance_mode(self, mode_string):
|
||||
if mode_string.lower() == "dark":
|
||||
|
Reference in New Issue
Block a user