I have this script in Tk and it works fine. I wanted to make it dark and ad hover options, so I changed it to CTk, but now it's not working. Can someone please help me fix this? I have both scripts inhere to show.

(This is part of a bigger script, where it checks multiple buttons to see if it is disabled. If so, show a Label.)

I think there's a problem with this line:

if Button['state'] == DISABLED:

This one works:

from tkinter import *

def ChangeState():
    Button.configure(state="disabled")
    if Button['state'] == DISABLED:
        Button.configure(bg="Green")

window = Tk()

Button = Button(window, text = "Button", command=ChangeState)
Button.pack()

window.mainloop()

This one doens't work:

from customtkinter import *

def ChangeState():
    Button.configure(state="disabled")
    if Button['state'] == DISABLED:
        Button.configure(fg_color="Green")

window = CTk()

Button = CTkButton(window, text = "Button", hover=False, command=ChangeState)
Button.pack()

window.mainloop()

0

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.