Class and tkinter problem

Paulo da Silva p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt
Thu Jan 7 02:29:46 EST 2021


Hi!

Does anybody know why cmd method isn't called when I change the button
state (clicking on it) in this example?
I know that this seems a weird class use. But why doesn't it work?
Thanks.

class C:
    from tkinter import Checkbutton
    import tkinter

    @staticmethod
    def cmd():
        print("Test")

    top=tkinter.Tk()
    cb=Checkbutton(command=cmd)
    cb.pack()

    @staticmethod
    def loop():
        C.top.mainloop()

c=C()
c.loop()


More information about the Python-list mailing list