def test_appearance_mode(self): print(" -> test_appearance_mode: ", end="") customtkinter.set_appearance_mode("light") self.root_ctk.config(fg_color=("green", "#FFFFFF")) assert self.root_ctk.cget("bg") == "green" customtkinter.set_appearance_mode("dark") assert self.root_ctk.cget("bg") == "#FFFFFF" print("successful")
class App(customtkinter.CTk): customtkinter.set_appearance_mode("dark") APP_NAME = "Bulk Barcode Generator" WIDTH = 600 HEIGHT = 450 MAIN_COLOR = "#5ea886" MAIN_COLOR_DARK = "#2D5862" MAIN_HOVER = "#05f4b7" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.title(App.APP_NAME) self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT)) self.minsize(App.WIDTH, App.HEIGHT) self.protocol("WM_DELETE_WINDOW", self.on_closing) # ============ create two CTkFrames ============ self.frame_left = customtkinter.CTkFrame(master=self, width=220, height=App.HEIGHT-40, corner_radius=5) self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E) self.frame_right = customtkinter.CTkFrame(master=self, width=350, height=App.HEIGHT-40, corner_radius=5) self.frame_right.place(relx=0.40, rely=0.5, anchor=tkinter.W) # # ============ frame_right ============ self.button_output = customtkinter.CTkButton(master=self.frame_right, border_color=App.MAIN_COLOR, fg_color=None, hover_color=App.MAIN_HOVER, height=28, text="Output Folder", command=self.button_outputFunc, border_width=3, corner_radius=10, text_font=('Calibri',12)) self.button_output.place(relx=0.05, rely=0.06, anchor=tkinter.NW) self.entry_output = customtkinter.CTkEntry(master=self.frame_right, width=320, height=38, corner_radius=5) self.entry_output.place(relx=0.05, rely=0.18, anchor=tkinter.NW) def button_outputFunc(self): self.entry_output.delete(0, 'end') filename = fd.askdirectory() self.entry_output.insert(0,str(filename)) pass def on_closing(self, event=0): self.destroy() def start(self): self.mainloop()
def change_appearance_mode(self, value): """ gets called by self.slider_1 """ if value == 0: self.label_1.set_text("mode: Light") customtkinter.set_appearance_mode("Light") elif value == 1: self.label_1.set_text("mode: Dark") customtkinter.set_appearance_mode("Dark") else: self.label_1.set_text("mode: System") customtkinter.set_appearance_mode("System")
import tkinter import customtkinter # <- import the CustomTkinter module 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" 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(app) top_tk.geometry("500x500") #app.minsize(200, 200) #app.maxsize(520, 520) #app.resizable(True, False) def button_function(): app.geometry(f"{200}x{200}") print("Button click", label_1.text_label.cget("text")) def slider_function(value): customtkinter.set_widget_scaling(value * 2) customtkinter.set_spacing_scaling(value * 2)
import customtkinter customtkinter.set_default_color_theme("blue") customtkinter.set_appearance_mode("dark") app = customtkinter.CTk() app.geometry("600x1000") app.grid_columnconfigure(0, weight=1) app.grid_columnconfigure(1, weight=1) app.grid_columnconfigure(2, weight=1) app.grid_columnconfigure(3, weight=1) f1 = customtkinter.CTkFrame(app, fg_color="gray10", corner_radius=0) f1.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="nsew") f1.grid_columnconfigure(0, weight=1) f2 = customtkinter.CTkFrame(app, fg_color="gray10", corner_radius=0) f2.grid(row=0, column=1, rowspan=1, columnspan=1, sticky="nsew") f2.grid_columnconfigure(0, weight=1) f3 = customtkinter.CTkFrame(app, fg_color="gray85", corner_radius=0) f3.grid(row=0, column=2, rowspan=1, columnspan=1, sticky="nsew") f3.grid_columnconfigure(0, weight=1) f4 = customtkinter.CTkFrame(app, fg_color="gray90", corner_radius=0) f4.grid(row=0, column=3, rowspan=1, columnspan=1, sticky="nsew") f4.grid_columnconfigure(0, weight=1) for i in range(0, 21, 1): b = customtkinter.CTkButton(f1,
import tkinter import customtkinter customtkinter.set_appearance_mode("System") # Other: "Dark", "Light" customtkinter.set_default_color_theme( "green") # Themes: "blue" (standard), "green", "dark-blue" class TestApp(customtkinter.CTk): def __init__(self): super().__init__() self.geometry(f"{1400}x{700}") self.title("CustomTkinter complete test") self.create_widgets_on_tk() self.create_widgets_on_ctk_frame() self.create_widgets_on_ctk_frame_customized() self.create_widgets_on_tk_frame_customized() def change_appearance_mode(self, value): """ gets called by self.slider_1 """ if value == 0: self.label_1.set_text("mode: Light") customtkinter.set_appearance_mode("Light") elif value == 1: self.label_1.set_text("mode: Dark") customtkinter.set_appearance_mode("Dark") else: self.label_1.set_text("mode: System") customtkinter.set_appearance_mode("System")
def change_mode(): if c1.get() == 0: customtkinter.set_appearance_mode("light") else: customtkinter.set_appearance_mode("dark")
def change_mode(self): if self.switch_2.get() == 1: customtkinter.set_appearance_mode("dark") else: customtkinter.set_appearance_mode("light")
import tkinter import tkinter.ttk as ttk import customtkinter customtkinter.set_appearance_mode("light") app = customtkinter.CTk() app.geometry("1400x480") app.title("CustomTkinter TTk Compatibility Test") app.grid_rowconfigure(0, weight=1) app.grid_columnconfigure((0, 1, 2, 3, 5, 6), weight=1) button_0 = customtkinter.CTkButton(app) button_0.grid(padx=20, pady=20, row=0, column=0) 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=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=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")