added state to CTkEntry, completed test for widget state

This commit is contained in:
Tom Schimansky
2022-05-22 19:45:42 +02:00
parent df1420cd02
commit eeeb85ec0d
2 changed files with 35 additions and 11 deletions

View File

@ -3,7 +3,7 @@ import customtkinter
root_tk = customtkinter.CTk()
root_tk.geometry("400x240")
root_tk.geometry("400x800")
root_tk.title("CustomTkinter Test")
@ -14,18 +14,34 @@ def change_state(widget):
widget.configure(state=tkinter.NORMAL)
def button_2_click():
print("button_2 clicked")
def widget_click():
print("widget clicked")
button_1 = customtkinter.CTkButton(master=root_tk, text="button_1", command=button_2_click)
button_1.pack(padx=20, pady=10)
button_1 = customtkinter.CTkButton(master=root_tk, 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.pack(padx=20, pady=10)
button_2.pack(padx=20, pady=(10, 20))
switch_1 = customtkinter.CTkSwitch(master=root_tk, 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.pack(padx=20, pady=(10, 20))
entry_1 = customtkinter.CTkEntry(master=root_tk, 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.pack(padx=20, pady=(10, 20))
checkbox_1 = customtkinter.CTkCheckBox(master=root_tk, 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.pack(padx=20, pady=(10, 20))
radiobutton_1 = customtkinter.CTkRadioButton(master=root_tk, 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.pack(padx=20, pady=(10, 20))
switch_1 = customtkinter.CTkSwitch(master=root_tk, text="switch_1", command=button_2_click)
switch_1.pack(padx=20, pady=10)
switch_2 = customtkinter.CTkSwitch(master=root_tk, text="Disable/Enable switch_1", command=lambda: change_state(switch_1))
switch_2.pack(padx=20, pady=10)
root_tk.mainloop()