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

@ -41,17 +41,17 @@ import customtkinter
customtkinter.set_appearance_mode("System") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue") # Themes: blue (default), dark-blue, green
root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window
root_tk.geometry("400x240")
app = customtkinter.CTk() # create CTk window like you do with the Tk window
app.geometry("400x240")
def button_function():
print("button pressed")
# Use CTkButton instead of tkinter Button
button = customtkinter.CTkButton(master=root_tk, text="CTkButton", command=button_function)
button = customtkinter.CTkButton(master=app, text="CTkButton", command=button_function)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
root_tk.mainloop()
app.mainloop()
```
which gives the following (macOS dark mode on):

View File

@ -2,6 +2,7 @@ __version__ = "4.0.1"
import os
import sys
from tkinter.constants import *
# import manager classes
from .settings import Settings

View File

@ -19,7 +19,7 @@ except Exception:
class AppearanceModeTracker:
callback_list = []
root_tk_list = []
app_list = []
update_loop_running = False
update_loop_interval = 500 # milliseconds
@ -40,12 +40,12 @@ class AppearanceModeTracker:
cls.callback_list.append(callback)
if widget is not None:
root_tk = cls.get_tk_root_of_widget(widget)
if root_tk not in cls.root_tk_list:
cls.root_tk_list.append(root_tk)
app = cls.get_tk_root_of_widget(widget)
if app not in cls.app_list:
cls.app_list.append(app)
if not cls.update_loop_running:
root_tk.after(500, cls.update)
app.after(500, cls.update)
cls.update_loop_running = True
@classmethod
@ -97,9 +97,9 @@ class AppearanceModeTracker:
cls.update_callbacks()
# find an existing tkinter.Tk object for the next call of .after()
for root_tk in cls.root_tk_list:
for app in cls.app_list:
try:
root_tk.after(cls.update_loop_interval, cls.update)
app.after(cls.update_loop_interval, cls.update)
return
except Exception:
continue

View File

@ -168,9 +168,9 @@ class ScalingTracker:
cls.update_scaling_callbacks_for_window(window)
# find an existing tkinter object for the next call of .after()
for root_tk in cls.window_widgets_dict.keys():
for app in cls.window_widgets_dict.keys():
try:
root_tk.after(cls.update_loop_interval, cls.check_dpi_scaling)
app.after(cls.update_loop_interval, cls.check_dpi_scaling)
return
except Exception:
continue

View File

@ -14,9 +14,8 @@ class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.title("CustomTkinter complex example")
self.title("CustomTkinter complex_example.py")
self.geometry(f"{App.WIDTH}x{App.HEIGHT}")
# self.minsize(App.WIDTH, App.HEIGHT)
self.protocol("WM_DELETE_WINDOW", self.on_closing) # call .on_closing() when app gets closed

View File

@ -12,7 +12,7 @@ PATH = os.path.dirname(os.path.realpath(__file__))
class App(customtkinter.CTk):
APP_NAME = "CustomTkinter background gradient image"
APP_NAME = "CustomTkinter example_background_image.py"
WIDTH = 900
HEIGHT = 600

View File

@ -1,5 +1,5 @@
import tkinter
import customtkinter # <- import the CustomTkinter module
import customtkinter
from PIL import Image, ImageTk # <- import PIL for the images
import os
@ -8,9 +8,9 @@ PATH = os.path.dirname(os.path.realpath(__file__))
customtkinter.set_appearance_mode("System") # 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("450x260")
root_tk.title("CustomTkinter button images")
app = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
app.geometry("450x260")
app.title("CustomTkinter example_button_images.py")
def button_function():
@ -29,10 +29,10 @@ add_user_image = ImageTk.PhotoImage(Image.open(PATH + "/test_images/add-user.png
chat_image = ImageTk.PhotoImage(Image.open(PATH + "/test_images/chat.png").resize((image_size, image_size), Image.ANTIALIAS))
home_image = ImageTk.PhotoImage(Image.open(PATH + "/test_images/home.png").resize((image_size, image_size), Image.ANTIALIAS))
root_tk.grid_rowconfigure(0, weight=1)
root_tk.grid_columnconfigure(0, weight=1, minsize=200)
app.grid_rowconfigure(0, weight=1)
app.grid_columnconfigure(0, weight=1, minsize=200)
frame_1 = customtkinter.CTkFrame(master=root_tk, width=250, height=240, corner_radius=15)
frame_1 = customtkinter.CTkFrame(master=app, width=250, height=240, corner_radius=15)
frame_1.grid(row=0, column=0, padx=20, pady=20, sticky="nsew")
frame_1.grid_columnconfigure(0, weight=1)
@ -56,9 +56,9 @@ button_4 = customtkinter.CTkButton(master=frame_1, image=home_image, text="", wi
corner_radius=10, fg_color="gray40", hover_color="gray25", command=button_function)
button_4.grid(row=3, column=1, columnspan=1, padx=20, pady=10, sticky="e")
button_5 = customtkinter.CTkButton(master=root_tk, image=add_user_image, text="Add User", width=130, height=70, border_width=3,
button_5 = customtkinter.CTkButton(master=app, image=add_user_image, text="Add User", width=130, height=70, border_width=3,
corner_radius=10, compound="bottom", border_color="#D35B58", fg_color=("gray84", "gray25"), hover_color="#C77C78",
command=button_function)
button_5.grid(row=0, column=1, padx=20, pady=20)
root_tk.mainloop()
app.mainloop()

View File

@ -1,12 +1,12 @@
import tkinter
import customtkinter # <- import the CustomTkinter module
import customtkinter
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
# customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
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 Test")
app = customtkinter.CTk() # create CTk window like you do with the Tk window
app.geometry("400x480")
app.title("CustomTkinter simple_example.py")
def button_function():
@ -23,7 +23,7 @@ def check_box_function():
y_padding = 13
frame_1 = customtkinter.CTkFrame(master=root_tk, corner_radius=15)
frame_1 = customtkinter.CTkFrame(master=app, corner_radius=15)
frame_1.pack(pady=20, padx=60, fill="both", expand=True)
label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
@ -58,4 +58,4 @@ s_var = tkinter.StringVar(value="on")
switch_1 = customtkinter.CTkSwitch(master=frame_1)
switch_1.pack(pady=y_padding, padx=10)
root_tk.mainloop()
app.mainloop()

View File

@ -3,7 +3,7 @@ import tkinter
app = tkinter.Tk()
app.geometry("400x350")
app.title("Standard Tkinter Test")
app.title("simple_example_standard_tkinter.py")
def button_function():

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()