mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added CTk class which overrides tkinter.Tk for automatic background color changes
This commit is contained in:
@ -6,22 +6,14 @@ import sys
|
||||
customtkinter.set_appearance_mode("System") # Other: "Light", "Dark"
|
||||
|
||||
|
||||
class App(tkinter.Tk):
|
||||
class App(customtkinter.CTk):
|
||||
|
||||
APP_NAME = "CustomTkinter complex example"
|
||||
WIDTH = 700
|
||||
HEIGHT = 500
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
customtkinter.enable_macos_darkmode()
|
||||
|
||||
tkinter.Tk.__init__(self, *args, **kwargs)
|
||||
|
||||
# color the background of the Tk window if mode is not System
|
||||
if customtkinter.get_appearance_mode() == "Dark":
|
||||
self.configure(bg="#323232") # set window background to dark color
|
||||
elif customtkinter.get_appearance_mode() == "Light":
|
||||
self.configure(bg="#ECECEC") # set window background to dark color
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.title(App.APP_NAME)
|
||||
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
|
||||
@ -164,7 +156,6 @@ class App(tkinter.Tk):
|
||||
print("Button pressed")
|
||||
|
||||
def on_closing(self, event=0):
|
||||
customtkinter.disable_macos_darkmode()
|
||||
self.destroy()
|
||||
|
||||
def start(self):
|
||||
|
Reference in New Issue
Block a user