CustomTkinter/examples/simple_example.py

58 lines
1.9 KiB
Python
Raw Normal View History

import tkinter
import customtkinter # <- import the CustomTkinter module
2021-03-04 20:27:46 +03:00
2022-01-22 22:28:59 +03:00
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
2022-01-08 02:29:53 +03:00
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)
2022-03-05 15:21:53 +03:00
root_tk.geometry("400x440")
root_tk.title("CustomTkinter Test")
2021-03-05 02:32:17 +03:00
def button_function():
2022-02-04 23:28:37 +03:00
print("Button click", label_1.text_label.cget("text"))
def slider_function(value):
progressbar_1.set(value)
def check_box_function():
print("checkbox_1:", checkbox_1.get())
y_padding = 13
frame_1 = customtkinter.CTkFrame(master=root_tk, corner_radius=15)
frame_1.pack(pady=20, padx=60, fill="both", expand=True)
label_1 = customtkinter.CTkLabel(master=frame_1)
label_1.pack(pady=y_padding, padx=10)
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
progressbar_1.pack(pady=y_padding, padx=10)
2022-02-23 00:38:40 +03:00
button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=8, command=button_function)
button_1.pack(pady=y_padding, padx=10)
# button_1.configure(state="disabled")
2022-01-08 02:29:53 +03:00
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function, from_=0, to=1)
slider_1.pack(pady=y_padding, padx=10)
2022-01-08 02:29:53 +03:00
slider_1.set(0.5)
2022-02-04 23:28:37 +03:00
entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="CTkEntry")
entry_1.pack(pady=y_padding, padx=10)
checkbox_1 = customtkinter.CTkCheckBox(master=frame_1, command=check_box_function)
checkbox_1.pack(pady=y_padding, padx=10)
radiobutton_var = tkinter.IntVar()
radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1)
radiobutton_1.pack(pady=y_padding, padx=10)
radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2)
radiobutton_2.pack(pady=y_padding, padx=10)
root_tk.mainloop()