在嵌套类中调用函数

时间:2017-01-11 10:40:36

标签: python-3.x class nested self-reference

我想从嵌套类(2)(类1中定义的类2)调用类(1)中定义的函数。类似于下面的代码:

class firstclass(object):
    def __init__(self, *args, **kwargs):
        #some code and functions...
    def afunction(self):
        #some code
    class nestedclass(tkinter.Frame):
        def __init__(self, parent):
            #some code
        def anotherfunction(self):
            #here I would like to call a function from the class firstclass from a button
            self.abutton = tkinter.Button(self.parent, text = "blabla", command = firstclass.afunction)
            self.abutton.grid(row = 0, column = 1,columnspan=1)

但是我不断错过所需的位置参数self。如何在命令选项中给它这个参数?

或任何建议如何解决这个问题? 非常感谢所有输入

0 个答案:

没有答案