mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fix switch and radiobutton background color #867, check if user set titlebar icon on Windows
This commit is contained in:
@ -62,19 +62,25 @@ class CTkToplevel(tkinter.Toplevel, CTkAppearanceModeBaseClass, CTkScalingBaseCl
|
||||
# set title of tkinter.Toplevel
|
||||
super().title("CTkToplevel")
|
||||
|
||||
# indicator variables
|
||||
self._iconbitmap_method_called = True
|
||||
self._state_before_windows_set_titlebar_color = None
|
||||
self._windows_set_titlebar_color_called = False # indicates if windows_set_titlebar_color was called, stays True until revert_withdraw_after_windows_set_titlebar_color is called
|
||||
self._withdraw_called_after_windows_set_titlebar_color = False # indicates if withdraw() was called after windows_set_titlebar_color
|
||||
self._iconify_called_after_windows_set_titlebar_color = False # indicates if iconify() was called after windows_set_titlebar_color
|
||||
self._block_update_dimensions_event = False
|
||||
|
||||
# set CustomTkinter titlebar icon (Windows only)
|
||||
if sys.platform.startswith("win"):
|
||||
self.after(200, self._windows_set_titlebar_icon)
|
||||
|
||||
# set titlebar color (Windows only)
|
||||
if sys.platform.startswith("win"):
|
||||
self._windows_set_titlebar_color(self._get_appearance_mode())
|
||||
|
||||
self.bind('<Configure>', self._update_dimensions_event)
|
||||
self.bind('<FocusIn>', self._focus_in_event)
|
||||
|
||||
self._block_update_dimensions_event = False
|
||||
|
||||
def destroy(self):
|
||||
self._disable_macos_dark_title_bar()
|
||||
|
||||
@ -190,6 +196,19 @@ class CTkToplevel(tkinter.Toplevel, CTkAppearanceModeBaseClass, CTkScalingBaseCl
|
||||
else:
|
||||
return super().cget(attribute_name)
|
||||
|
||||
def wm_iconbitmap(self, bitmap=None, default=None):
|
||||
self._iconbitmap_method_called = True
|
||||
super().wm_iconbitmap(bitmap, default)
|
||||
|
||||
def _windows_set_titlebar_icon(self):
|
||||
try:
|
||||
# if not the user already called iconbitmap method, set icon
|
||||
if not self._iconbitmap_method_called:
|
||||
customtkinter_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
self.iconbitmap(os.path.join(customtkinter_directory, "assets", "icons", "CustomTkinter_icon_Windows.ico"))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def _enable_macos_dark_title_bar(cls):
|
||||
if sys.platform == "darwin" and not cls._deactivate_macos_window_header_manipulation: # macOS
|
||||
|
Reference in New Issue
Block a user