-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CTk (tkinter.Tk)
Theoretically you could also use the normal tkinter.Tk
class to create a window and place CTK widgets on it,
but it is highly recommended to use the customtkinter.CTk
to create the window if you use CustomTkinter.
Because only with the CTk
window you get a dark window background and header which adapts to the dark/light mode
set by customtkinter.set_appearance_mode(...)
.
Apart from the changing background and header color, the CTk
class behaves exactly like the tkinter.Tk
class.
app = customtkinter.CTk()
app.geometry(f"{600}x{500}")
app.title("CTk example")
... program ...
app.mainloop()
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry(f"{600}x{500}")
self.title("CTk example")
... create widgets ...
... program methods ...
app = App()
app.mainloop()
argument | value |
---|---|
fg_color | window background color, tuple: (light_color, dark_color) or single color |
-
All attributes can be configured and updated.
app.configure(fg_color=new_fg_color)
-
Pass attribute name as string and get current value of attribute.
fg_color = app.cget("fg_color") ...
-
Set title of window.
-
Set geometry and positions of the window like this:
"<width>x<height>"
or"<width>x<height>+<x_pos>+<y_pos>"
-
Set minimal window size.
-
Set max window size.
-
Define, if width and/or height should be resizablee with bool values.
-
Execute command after milliseconds without blocking the main loop.
-
Hide window and icon. Restore it with .deiconify().
-
Iconifies the window. Restore it with .deiconify().
-
Deiconify the window.
-
Returns the window state:
'normal', 'iconic' or 'withdrawn'
CustomTkinter by Tom Schimansky 2022
The Github Wiki is outdated, the new documentation can be found at: