changed root_tk name to app in all exmaples and tests

This commit is contained in:
Tom Schimansky
2022-05-22 20:26:31 +02:00
parent 0c7abdaec5
commit 8cafed1b06
21 changed files with 124 additions and 130 deletions

View File

@ -1,9 +1,7 @@
from tkinter.constants import CENTER, LEFT
import tkinter
import tkinter.messagebox
from tkinter import filedialog as fd
import customtkinter # <- import the CustomTkinter module
import os
import customtkinter
class App(customtkinter.CTk):

View File

@ -1,5 +1,4 @@
import customtkinter
import tkinter
customtkinter.set_default_color_theme("blue")
customtkinter.set_appearance_mode("dark")

View File

@ -1,4 +1,3 @@
import tkinter
import customtkinter

View File

@ -1,22 +1,21 @@
import tkinter
import customtkinter
root_tk = customtkinter.CTk()
root_tk.geometry("400x240")
app = customtkinter.CTk()
app.geometry("400x240")
def button_function():
top = customtkinter.CTkToplevel(root_tk)
top = customtkinter.CTkToplevel(app)
root_tk.after(1000, top.iconify) # hide toplevel
root_tk.after(1500, top.deiconify) # show toplevel
root_tk.after(2500, root_tk.iconify) # hide root_tk
root_tk.after(3000, root_tk.deiconify) # show root_tk
root_tk.after(4000, root_tk.destroy) # destroy everything
app.after(1000, top.iconify) # hide toplevel
app.after(1500, top.deiconify) # show toplevel
app.after(2500, app.iconify) # hide app
app.after(3000, app.deiconify) # show app
app.after(4000, app.destroy) # destroy everything
button = customtkinter.CTkButton(root_tk, command=button_function)
button = customtkinter.CTkButton(app, command=button_function)
button.pack(pady=20, padx=20)
root_tk.mainloop()
app.mainloop()

View File

@ -3,8 +3,8 @@ import tkinter
# customtkinter.set_appearance_mode("light")
root_tk = customtkinter.CTk()
root_tk.geometry("600x500")
app = customtkinter.CTk()
app.geometry("600x500")
menu = tkinter.Menu(tearoff=0, bd=0, relief=tkinter.FLAT, activeforeground="red")
menu.add_command(label="System")
@ -45,9 +45,9 @@ class CTkMenu(tkinter.Toplevel):
def open_menu():
menu = CTkMenu(root_tk, button.winfo_rootx(), button.winfo_rooty() + button.winfo_height() + 4, ["Option 1", "Option 2", "Point 3"])
menu = CTkMenu(app, button.winfo_rootx(), button.winfo_rooty() + button.winfo_height() + 4, ["Option 1", "Option 2", "Point 3"])
button = customtkinter.CTkButton(command=open_menu, height=50)
button.pack(pady=20)
root_tk.mainloop()
app.mainloop()

View File

@ -6,17 +6,17 @@ customtkinter.ScalingTracker.set_window_scaling(0.5)
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
root_tk.geometry("400x600")
root_tk.title("CustomTkinter manual scaling test")
app = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
app.geometry("400x600")
app.title("CustomTkinter manual scaling test")
#root_tk.minsize(200, 200)
#root_tk.maxsize(520, 520)
#root_tk.resizable(True, False)
#app.minsize(200, 200)
#app.maxsize(520, 520)
#app.resizable(True, False)
def button_function():
root_tk.geometry(f"{200}x{200}")
app.geometry(f"{200}x{200}")
print("Button click", label_1.text_label.cget("text"))
@ -29,7 +29,7 @@ def slider_function(value):
y_padding = 13
frame_1 = customtkinter.CTkFrame(master=root_tk, height=550, width=300)
frame_1 = customtkinter.CTkFrame(master=app, height=550, width=300)
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
label_1.place(relx=0.5, y=50, anchor=tkinter.CENTER)
@ -53,4 +53,4 @@ s_var = tkinter.StringVar(value="on")
switch_1 = customtkinter.CTkSwitch(master=frame_1)
switch_1.place(relx=0.5, y=450, anchor=tkinter.CENTER)
root_tk.mainloop()
app.mainloop()

View File

@ -6,20 +6,20 @@ customtkinter.ScalingTracker.set_window_scaling(0.5)
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
root_tk.geometry("400x480")
root_tk.title("CustomTkinter manual scaling test")
app = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
app.geometry("400x480")
app.title("CustomTkinter manual scaling test")
top_tk = customtkinter.CTkToplevel(root_tk)
top_tk = customtkinter.CTkToplevel(app)
top_tk.geometry("500x500")
#root_tk.minsize(200, 200)
#root_tk.maxsize(520, 520)
#root_tk.resizable(True, False)
#app.minsize(200, 200)
#app.maxsize(520, 520)
#app.resizable(True, False)
def button_function():
root_tk.geometry(f"{200}x{200}")
app.geometry(f"{200}x{200}")
print("Button click", label_1.text_label.cget("text"))
@ -32,7 +32,7 @@ def slider_function(value):
y_padding = 13
frame_1 = customtkinter.CTkFrame(master=root_tk)
frame_1 = customtkinter.CTkFrame(master=app)
frame_1.pack(pady=20, padx=60, fill="both", expand=True)
label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
label_1.pack(pady=y_padding, padx=10)
@ -78,4 +78,4 @@ radiobutton_2.pack(pady=y_padding, padx=10)
switch_1 = customtkinter.CTkSwitch(master=top_tk)
switch_1.pack(pady=y_padding, padx=10)
root_tk.mainloop()
app.mainloop()

View File

@ -1,5 +1,4 @@
import customtkinter
import tkinter
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("blue")
@ -22,8 +21,8 @@ def button_click_event():
button = customtkinter.CTkButton(app, text="Open Dialog", command=button_click_event)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER)
c1 = customtkinter.CTkCheckBox(app, text="dark mode", command=change_mode)
c1.place(relx=0.5, rely=0.8, anchor=tkinter.CENTER)
c1.place(relx=0.5, rely=0.8, anchor=customtkinter.CENTER)
app.mainloop()
app.mainloop()

View File

@ -1,63 +1,63 @@
import tkinter
import customtkinter # <- import the CustomTkinter module
import customtkinter
TEST_CONFIGURE = True
TEST_REMOVING = False
root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
root_tk.geometry("400x600")
root_tk.title("Tkinter Variable Test")
app = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
app.geometry("400x600")
app.title("Tkinter Variable Test")
txt_var = tkinter.StringVar(value="")
entry_1 = customtkinter.CTkEntry(root_tk, width=200, textvariable=txt_var)
entry_1 = customtkinter.CTkEntry(app, width=200, textvariable=txt_var)
entry_1.pack(pady=15)
txt_var.set("new text wjkfjdshkjfb")
if TEST_CONFIGURE: entry_1.configure(textvariable=txt_var)
if TEST_REMOVING: entry_1.configure(textvariable="")
label_1 = customtkinter.CTkLabel(root_tk, width=200, textvariable=txt_var)
label_1 = customtkinter.CTkLabel(app, width=200, textvariable=txt_var)
label_1.pack(pady=15)
if TEST_CONFIGURE: label_1.configure(textvariable=txt_var)
if TEST_REMOVING: label_1.configure(textvariable="")
button_1 = customtkinter.CTkButton(root_tk, width=200, textvariable=txt_var)
button_1 = customtkinter.CTkButton(app, width=200, textvariable=txt_var)
button_1.pack(pady=15)
int_var = tkinter.IntVar(value=10)
if TEST_CONFIGURE: button_1.configure(textvariable=int_var)
if TEST_REMOVING: button_1.configure(textvariable="")
slider_1 = customtkinter.CTkSlider(root_tk, width=200, from_=0, to=3, variable=int_var)
slider_1 = customtkinter.CTkSlider(app, width=200, from_=0, to=3, variable=int_var)
slider_1.pack(pady=15)
if TEST_CONFIGURE: slider_1.configure(variable=int_var)
if TEST_REMOVING: slider_1.configure(variable="")
int_var.set(2)
slider_2 = customtkinter.CTkSlider(root_tk, width=200, from_=0, to=3, variable=int_var)
slider_2 = customtkinter.CTkSlider(app, width=200, from_=0, to=3, variable=int_var)
slider_2.pack(pady=15)
if TEST_CONFIGURE: slider_2.configure(variable=int_var)
if TEST_REMOVING: slider_2.configure(variable="")
label_2 = customtkinter.CTkLabel(root_tk, width=200, textvariable=int_var)
label_2 = customtkinter.CTkLabel(app, width=200, textvariable=int_var)
label_2.pack(pady=15)
progress_1 = customtkinter.CTkProgressBar(root_tk, width=200, variable=int_var)
progress_1 = customtkinter.CTkProgressBar(app, width=200, variable=int_var)
progress_1.pack(pady=15)
if TEST_CONFIGURE: progress_1.configure(variable=int_var)
if TEST_REMOVING: progress_1.configure(variable="")
check_var = tkinter.StringVar(value="on")
check_1 = customtkinter.CTkCheckBox(root_tk, text="check 1", variable=check_var, onvalue="on", offvalue="off")
check_1 = customtkinter.CTkCheckBox(app, text="check 1", variable=check_var, onvalue="on", offvalue="off")
check_1.pack(pady=15)
if TEST_CONFIGURE: check_1.configure(variable=check_var)
if TEST_REMOVING: check_1.configure(variable="")
print("check_1", check_1.get())
check_2 = customtkinter.CTkCheckBox(root_tk, text="check 2", variable=check_var, onvalue="on", offvalue="off")
check_2 = customtkinter.CTkCheckBox(app, text="check 2", variable=check_var, onvalue="on", offvalue="off")
check_2.pack(pady=15)
if TEST_CONFIGURE: check_2.configure(variable=check_var)
if TEST_REMOVING: check_2.configure(variable="")
label_3 = customtkinter.CTkLabel(root_tk, width=200, textvariable=check_var)
label_3 = customtkinter.CTkLabel(app, width=200, textvariable=check_var)
label_3.pack(pady=15)
label_3.configure(textvariable=check_var)
@ -65,10 +65,10 @@ def switch_event():
print("switch event")
s_var = tkinter.StringVar(value="on")
switch_1 = customtkinter.CTkSwitch(master=root_tk, variable=s_var, textvariable=s_var, onvalue="on", offvalue="off", command=switch_event)
switch_1 = customtkinter.CTkSwitch(master=app, variable=s_var, textvariable=s_var, onvalue="on", offvalue="off", command=switch_event)
switch_1.pack(pady=20, padx=10)
switch_1 = customtkinter.CTkSwitch(master=root_tk, variable=s_var, textvariable=s_var, onvalue="on", offvalue="off")
switch_1 = customtkinter.CTkSwitch(master=app, variable=s_var, textvariable=s_var, onvalue="on", offvalue="off")
switch_1.pack(pady=20, padx=10)
#switch_1.toggle()
root_tk.mainloop()
app.mainloop()

View File

@ -4,28 +4,28 @@ import customtkinter
customtkinter.set_appearance_mode("light")
root_tk = customtkinter.CTk()
root_tk.geometry("1400x480")
root_tk.title("CustomTkinter TTk Compatibility Test")
app = customtkinter.CTk()
app.geometry("1400x480")
app.title("CustomTkinter TTk Compatibility Test")
root_tk.grid_rowconfigure(0, weight=1)
root_tk.grid_columnconfigure((0, 1, 2, 3, 5, 6), weight=1)
app.grid_rowconfigure(0, weight=1)
app.grid_columnconfigure((0, 1, 2, 3, 5, 6), weight=1)
button_0 = customtkinter.CTkButton(root_tk)
button_0 = customtkinter.CTkButton(app)
button_0.grid(padx=20, pady=20, row=0, column=0)
frame_1 = tkinter.Frame(master=root_tk)
frame_1 = tkinter.Frame(master=app)
frame_1.grid(padx=20, pady=20, row=0, column=1, sticky="nsew")
button_1 = customtkinter.CTkButton(frame_1, text="tkinter.Frame")
button_1.pack(pady=20, padx=20)
frame_2 = tkinter.LabelFrame(master=root_tk, text="Tkinter LabelFrame")
frame_2 = tkinter.LabelFrame(master=app, text="Tkinter LabelFrame")
frame_2.grid(padx=20, pady=20, row=0, column=2, sticky="nsew")
button_2 = customtkinter.CTkButton(frame_2, text="tkinter.LabelFrame")
button_2.pack(pady=20, padx=20)
frame_3 = customtkinter.CTkFrame(master=root_tk)
frame_3 = customtkinter.CTkFrame(master=app)
frame_3.grid(padx=20, pady=20, row=0, column=3, sticky="nsew")
label_3 = customtkinter.CTkLabel(master=frame_3, text="CTkFrame Label", fg_color=("gray95", "gray15"))
label_3.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="ew")
@ -34,17 +34,17 @@ button_3.grid(row=1, column=0, padx=20)
frame_3.grid_rowconfigure(1, weight=1)
frame_3.grid_columnconfigure((0, ), weight=1)
frame_4 = ttk.Frame(master=root_tk)
frame_4 = ttk.Frame(master=app)
frame_4.grid(padx=20, pady=20, row=0, column=4, sticky="nsew")
button_4 = customtkinter.CTkButton(frame_4, text="ttk.Frame")
button_4.pack(pady=20, padx=20)
frame_5 = ttk.LabelFrame(master=root_tk, text="TTk LabelFrame")
frame_5 = ttk.LabelFrame(master=app, text="TTk LabelFrame")
frame_5.grid(padx=20, pady=20, row=0, column=5, sticky="nsew")
button_5 = customtkinter.CTkButton(frame_5)
button_5.pack(pady=20, padx=20)
frame_6 = ttk.Notebook(master=root_tk)
frame_6 = ttk.Notebook(master=app)
frame_6.grid(padx=20, pady=20, row=0, column=6, sticky="nsew")
button_6 = customtkinter.CTkButton(frame_6, text="ttk.Notebook")
button_6.pack(pady=20, padx=20)
@ -52,4 +52,4 @@ button_6.pack(pady=20, padx=20)
ttk_style = ttk.Style()
ttk_style.configure(frame_3.winfo_class(), background='red')
root_tk.mainloop()
app.mainloop()

View File

@ -1,25 +1,25 @@
import customtkinter
root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
root_tk.geometry("400x650")
root_tk.title("test_vertical_widgets")
app = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
app.geometry("400x650")
app.title("test_vertical_widgets")
root_tk.grid_columnconfigure(0, weight=1)
root_tk.grid_rowconfigure((0, 1, 2, 3), weight=1)
app.grid_columnconfigure(0, weight=1)
app.grid_rowconfigure((0, 1, 2, 3), weight=1)
progressbar_1 = customtkinter.CTkProgressBar(root_tk, orient="horizontal")
progressbar_1 = customtkinter.CTkProgressBar(app, orient="horizontal")
progressbar_1.grid(row=0, column=0, pady=20, padx=20)
progressbar_2 = customtkinter.CTkProgressBar(root_tk, orient="vertical")
progressbar_2 = customtkinter.CTkProgressBar(app, orient="vertical")
progressbar_2.grid(row=1, column=0, pady=20, padx=20)
slider_1 = customtkinter.CTkSlider(root_tk, orient="horizontal", command=progressbar_1.set,
slider_1 = customtkinter.CTkSlider(app, orient="horizontal", command=progressbar_1.set,
button_corner_radius=3, button_length=20)
slider_1.grid(row=2, column=0, pady=20, padx=20)
slider_2 = customtkinter.CTkSlider(root_tk, orient="vertical", command=progressbar_2.set,
slider_2 = customtkinter.CTkSlider(app, orient="vertical", command=progressbar_2.set,
button_corner_radius=3, button_length=20)
slider_2.grid(row=3, column=0, pady=20, padx=20)
root_tk.mainloop()
app.mainloop()

View File

@ -2,9 +2,9 @@ import tkinter
import customtkinter
root_tk = customtkinter.CTk()
root_tk.geometry("400x800")
root_tk.title("CustomTkinter Test")
app = customtkinter.CTk()
app.geometry("400x800")
app.title("CustomTkinter Test")
def change_state(widget):
@ -18,30 +18,30 @@ def widget_click():
print("widget clicked")
button_1 = customtkinter.CTkButton(master=root_tk, text="button_1", command=widget_click)
button_1 = customtkinter.CTkButton(master=app, text="button_1", command=widget_click)
button_1.pack(padx=20, pady=(20, 10))
button_2 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable button_1", command=lambda: change_state(button_1))
button_2 = customtkinter.CTkButton(master=app, text="Disable/Enable button_1", command=lambda: change_state(button_1))
button_2.pack(padx=20, pady=(10, 20))
switch_1 = customtkinter.CTkSwitch(master=root_tk, text="switch_1", command=widget_click)
switch_1 = customtkinter.CTkSwitch(master=app, text="switch_1", command=widget_click)
switch_1.pack(padx=20, pady=(20, 10))
button_2 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable switch_1", command=lambda: change_state(switch_1))
button_2 = customtkinter.CTkButton(master=app, text="Disable/Enable switch_1", command=lambda: change_state(switch_1))
button_2.pack(padx=20, pady=(10, 20))
entry_1 = customtkinter.CTkEntry(master=root_tk, placeholder_text="entry_1")
entry_1 = customtkinter.CTkEntry(master=app, placeholder_text="entry_1")
entry_1.pack(padx=20, pady=(20, 10))
button_3 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable entry_1", command=lambda: change_state(entry_1))
button_3 = customtkinter.CTkButton(master=app, text="Disable/Enable entry_1", command=lambda: change_state(entry_1))
button_3.pack(padx=20, pady=(10, 20))
checkbox_1 = customtkinter.CTkCheckBox(master=root_tk, text="checkbox_1")
checkbox_1 = customtkinter.CTkCheckBox(master=app, text="checkbox_1")
checkbox_1.pack(padx=20, pady=(20, 10))
button_4 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable checkbox_1", command=lambda: change_state(checkbox_1))
button_4 = customtkinter.CTkButton(master=app, text="Disable/Enable checkbox_1", command=lambda: change_state(checkbox_1))
button_4.pack(padx=20, pady=(10, 20))
radiobutton_1 = customtkinter.CTkRadioButton(master=root_tk, text="radiobutton_1")
radiobutton_1 = customtkinter.CTkRadioButton(master=app, text="radiobutton_1")
radiobutton_1.pack(padx=20, pady=(20, 10))
button_5 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable entry_1", command=lambda: change_state(radiobutton_1))
button_5 = customtkinter.CTkButton(master=app, text="Disable/Enable entry_1", command=lambda: change_state(radiobutton_1))
button_5.pack(padx=20, pady=(10, 20))
root_tk.mainloop()
app.mainloop()