mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added disabled state to CTkSwitch
This commit is contained in:
@@ -32,7 +32,6 @@ class App(customtkinter.CTk):
|
||||
height=App.HEIGHT-40,
|
||||
corner_radius=5)
|
||||
self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E)
|
||||
print(self.frame_left.widget_scaling)
|
||||
|
||||
self.frame_right = customtkinter.CTkFrame(master=self,
|
||||
width=350,
|
||||
@@ -65,4 +64,4 @@ class App(customtkinter.CTk):
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
app.start()
|
||||
app.start()
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import tkinter
|
||||
import customtkinter # <- import the CustomTkinter module
|
||||
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
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("400x240")
|
||||
root_tk.title("CustomTkinter Test")
|
||||
|
||||
|
||||
def change_button_2_state():
|
||||
if button_2.state == tkinter.NORMAL:
|
||||
button_2.configure(state=tkinter.DISABLED)
|
||||
elif button_2.state == tkinter.DISABLED:
|
||||
button_2.configure(state=tkinter.NORMAL)
|
||||
|
||||
|
||||
def button_2_click():
|
||||
print("button_2 clicked")
|
||||
|
||||
|
||||
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=200, corner_radius=15)
|
||||
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
button_1 = customtkinter.CTkButton(master=frame_1, text="Disable/Enable Button_2",
|
||||
corner_radius=10, command=change_button_2_state, width=200)
|
||||
button_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
|
||||
|
||||
button_2 = customtkinter.CTkButton(master=frame_1, text="Button_2",
|
||||
corner_radius=10, command=button_2_click)
|
||||
button_2.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
|
||||
|
||||
root_tk.mainloop()
|
||||
@@ -15,11 +15,9 @@ class ExampleApp(customtkinter.CTk):
|
||||
window = customtkinter.CTkToplevel(self)
|
||||
window.geometry("400x200")
|
||||
|
||||
print(window.master.winfo_class())
|
||||
|
||||
label = customtkinter.CTkLabel(window, text="CTkToplevel window")
|
||||
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
|
||||
|
||||
|
||||
app = ExampleApp()
|
||||
app.mainloop()
|
||||
app.mainloop()
|
||||
|
||||
@@ -25,7 +25,8 @@ def button_function():
|
||||
|
||||
def slider_function(value):
|
||||
customtkinter.set_widget_scaling(value * 2)
|
||||
customtkinter.ScalingTracker.set_window_scaling(value * 2)
|
||||
customtkinter.set_spacing_scaling(value * 2)
|
||||
customtkinter.set_window_scaling(value * 2)
|
||||
progressbar_1.set(value)
|
||||
|
||||
|
||||
|
||||
31
test/manual_integration_tests/test_widget_states.py
Normal file
31
test/manual_integration_tests/test_widget_states.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import tkinter
|
||||
import customtkinter
|
||||
|
||||
|
||||
root_tk = customtkinter.CTk()
|
||||
root_tk.geometry("400x240")
|
||||
root_tk.title("CustomTkinter Test")
|
||||
|
||||
|
||||
def change_state(widget):
|
||||
if widget.state == tkinter.NORMAL:
|
||||
widget.configure(state=tkinter.DISABLED)
|
||||
elif widget.state == tkinter.DISABLED:
|
||||
widget.configure(state=tkinter.NORMAL)
|
||||
|
||||
|
||||
def button_2_click():
|
||||
print("button_2 clicked")
|
||||
|
||||
|
||||
button_1 = customtkinter.CTkButton(master=root_tk, text="button_1", command=button_2_click)
|
||||
button_1.pack(padx=20, pady=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)
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user