1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Trying to make it CTk, but STATE not working

Discussão em 'Python' iniciado por Stack, Novembro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I have this script in Tk and it works fine. I wanted to make it dark, so I changed it to CTk, but now it's not working. Can someone please help me with 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()

    Continue reading...

Compartilhe esta Página