mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
architecture fixes
This commit is contained in:
@@ -63,10 +63,7 @@ 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()
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self._appearance_mode == 1:
|
||||
self._windows_set_titlebar_color("dark")
|
||||
else:
|
||||
self._windows_set_titlebar_color("light")
|
||||
self._windows_set_titlebar_color(self._get_appearance_mode())
|
||||
|
||||
self.bind('<Configure>', self._update_dimensions_event)
|
||||
self.bind('<FocusIn>', self._focus_in_event)
|
||||
@@ -97,12 +94,12 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
# detected_width = event.width
|
||||
# detected_height = event.height
|
||||
|
||||
if self._current_width != round(detected_width / self._window_scaling) or self._current_height != round(detected_height / self._window_scaling):
|
||||
self._current_width = round(detected_width / self._window_scaling) # adjust current size according to new size given by event
|
||||
self._current_height = round(detected_height / self._window_scaling) # _current_width and _current_height are independent of the scale
|
||||
if self._current_width != self._reverse_window_scaling(detected_width) or self._current_height != self._reverse_window_scaling(detected_height):
|
||||
self._current_width = self._reverse_window_scaling(detected_width) # adjust current size according to new size given by event
|
||||
self._current_height = self._reverse_window_scaling(detected_height) # _current_width and _current_height are independent of the scale
|
||||
|
||||
def _set_scaling(self, new_widget_scaling, new_window_scaling):
|
||||
self._window_scaling = new_window_scaling
|
||||
super()._set_scaling(new_widget_scaling, new_window_scaling)
|
||||
|
||||
# block update_dimensions_event to prevent current_width and current_height to get updated
|
||||
self._block_update_dimensions_event = True
|
||||
@@ -164,12 +161,9 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
self._last_resizable_args = ([], {"width": width, "height": height})
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self._appearance_mode == 1:
|
||||
self._windows_set_titlebar_color("dark")
|
||||
else:
|
||||
self._windows_set_titlebar_color("light")
|
||||
self._windows_set_titlebar_color(self._get_appearance_mode())
|
||||
|
||||
def minsize(self, width=None, height=None):
|
||||
def minsize(self, width: int = None, height: int = None):
|
||||
self._min_width = width
|
||||
self._min_height = height
|
||||
if self._current_width < width:
|
||||
@@ -178,7 +172,7 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
self._current_height = height
|
||||
super().minsize(self._apply_window_scaling(self._min_width), self._apply_window_scaling(self._min_height))
|
||||
|
||||
def maxsize(self, width=None, height=None):
|
||||
def maxsize(self, width: int = None, height: int = None):
|
||||
self._max_width = width
|
||||
self._max_height = height
|
||||
if self._current_width > width:
|
||||
@@ -297,16 +291,10 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
|
||||
else:
|
||||
pass # wait for update or mainloop to be called
|
||||
|
||||
def _set_appearance_mode(self, mode_string):
|
||||
if mode_string.lower() == "dark":
|
||||
self._appearance_mode = 1
|
||||
elif mode_string.lower() == "light":
|
||||
self._appearance_mode = 0
|
||||
def _set_appearance_mode(self, mode_string: str):
|
||||
super()._set_appearance_mode(mode_string)
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self._appearance_mode == 1:
|
||||
self._windows_set_titlebar_color("dark")
|
||||
else:
|
||||
self._windows_set_titlebar_color("light")
|
||||
self._windows_set_titlebar_color(mode_string)
|
||||
|
||||
super().configure(bg=self._apply_appearance_mode(self._fg_color))
|
||||
|
||||
Reference in New Issue
Block a user