-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CTkToplevel
CTkToplevel works exactly like the Tkinter.Toplevel
, and should be used to create more than one window.
import tkinter
import customtkinter
class ExampleApp(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("500x400")
self.button = customtkinter.CTkButton(self, text="Create Toplevel", command=self.create_toplevel)
self.button.pack(side="top", padx=40, pady=40)
def create_toplevel(self):
window = customtkinter.CTkToplevel(self)
window.geometry("400x200")
# create label on CTkToplevel window
label = customtkinter.CTkLabel(window, text="CTkToplevel window")
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
app = ExampleApp()
app.mainloop()
The example code results in the following windows:
argument | value |
---|---|
fg_color | window background color, tuple: (light_color, dark_color) or single color |
-
All attributes can be configured and updated.
toplevel.configure(fg_color=new_fg_color)
-
Pass attribute name as string and get current value of attribute.
fg_color = toplevel.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: