CustomTkinter/examples/simple_example.py

50 lines
1.6 KiB
Python
Raw Normal View History

2021-03-04 20:27:46 +03:00
import tkinter
2021-03-05 18:28:54 +03:00
import customtkinter # <- import the CustomTkinter module
2021-03-04 20:27:46 +03:00
2021-07-13 12:39:52 +03:00
customtkinter.enable_macos_darkmode()
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
2021-08-25 18:02:16 +03:00
# customtkinter.set_theme_color(("red2", "red3"), ("red3", "red4"))
2021-03-05 18:26:47 +03:00
2021-03-05 18:28:54 +03:00
root_tk = tkinter.Tk() # create the Tk window like you normally do
2021-08-25 18:02:16 +03:00
root_tk.geometry("400x300")
2021-03-05 18:28:54 +03:00
root_tk.title("CustomTkinter Test")
2021-03-05 02:32:17 +03:00
2021-03-04 20:27:46 +03:00
def button_function():
2021-09-13 15:27:29 +03:00
print("Button click")
2021-03-04 20:27:46 +03:00
2021-03-05 18:26:47 +03:00
def slider_function(value):
progressbar_1.set(value)
2021-09-13 15:27:29 +03:00
def check_box_function():
print("checkbox_1:", checkbox_1.get())
2021-08-25 18:02:16 +03:00
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=260, corner_radius=15)
2021-03-05 18:26:47 +03:00
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
label_1 = customtkinter.CTkLabel(master=frame_1)
label_1.place(relx=0.5, rely=0.1, anchor=tkinter.CENTER)
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
progressbar_1.place(relx=0.5, rely=0.25, anchor=tkinter.CENTER)
button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=10, command=button_function)
2021-08-25 18:02:16 +03:00
button_1.place(relx=0.5, rely=0.4, anchor=tkinter.CENTER)
# button_1.configure(state="disabled")
2021-07-23 01:44:13 +03:00
2021-09-13 15:27:29 +03:00
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function, from_=0, to=2)
2021-08-25 18:02:16 +03:00
slider_1.place(relx=0.5, rely=0.55, anchor=tkinter.CENTER)
2021-09-13 15:27:29 +03:00
slider_1.set(1.5)
2021-03-05 18:26:47 +03:00
entry_1 = customtkinter.CTkEntry(master=frame_1)
2021-08-25 18:02:16 +03:00
entry_1.place(relx=0.5, rely=0.75, anchor=tkinter.CENTER)
2021-09-13 15:27:29 +03:00
checkbox_1 = customtkinter.CTkCheckBox(master=frame_1, command=check_box_function)
2021-08-25 18:02:16 +03:00
checkbox_1.place(relx=0.5, rely=0.9, anchor=tkinter.CENTER)
2021-03-05 18:26:47 +03:00
2021-03-05 18:28:54 +03:00
root_tk.mainloop()
2021-03-05 18:26:47 +03:00
customtkinter.disable_macos_darkmode()