在PythonTkinter事件中从类外部调用方法

2024-06-30 08:43:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我想调用另一个类中的方法,并在Python中单击按钮时对父类进行更改。解释一下,在Tkinter可视化编程中,我单击按钮来更改主窗口,我不能用另一个类方法更改主窗口中的属性。在

我收到下面的错误消息。在

Exception in Tkinter callback Traceback (most recent call last):

File "/usr/lib/python3.5/tkinter/_ init _.py", line 1553, in _ call _

return self.func(*args) TypeError: buton_goster() missing 1 required positional argument: 'event'


class Butonol(object): #Button class


    def __init__(self):
        ...

    def buton_goster(self, event ): # Properties kisminda ozellik gosterir

        Test.countshow = Test.countshow + 1;
        if(Test.countshow >1):
            Test.props0.pack_forget()
            Test.props.pack_forget()
            ...

这是测试课

^{pr2}$

Tags: 方法intestselfeventinittkinterdef