Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从GUI类继承用户输入以使用子类提取数据?_Python_Class_Oop_Inheritance_Subclass - Fatal编程技术网

Python 从GUI类继承用户输入以使用子类提取数据?

Python 从GUI类继承用户输入以使用子类提取数据?,python,class,oop,inheritance,subclass,Python,Class,Oop,Inheritance,Subclass,我目前正在开发一个应用程序,它从GUI获取用户输入数据,根据用户输入检索数据,并绘制数据。我创建了两个类,一个用于GUI,另一个用于数据提取(GUI的子类),我希望运行代码,以便在用户将所有必要的参数输入GUI后,当他们单击“绘图”按钮时,数据提取类运行 class GUI: def __init__(self,window): self.window = window self.IDlabel = tk.Label(text='ID:

我目前正在开发一个应用程序,它从GUI获取用户输入数据,根据用户输入检索数据,并绘制数据。我创建了两个类,一个用于GUI,另一个用于数据提取(GUI的子类),我希望运行代码,以便在用户将所有必要的参数输入GUI后,当他们单击“绘图”按钮时,数据提取类运行

class GUI:
    def __init__(self,window):
        self.window = window
        
        self.IDlabel = tk.Label(text='ID: ')
        self.IDlabel.grid(row=0,column=0,sticky='w')
        self.ID = tk.StringVar()
        self.IDentry = tk.Entry(textvariable=self.ID,validate='focusout',validatecommand=self.get_ID)
        self.IDentry.grid(row=0,column=1,sticky='e')

        self.plot = tk.Button(text='Plot',width=5,height=1)
        self.plot.grid(row=7,column=9,sticky='e')
在另一个文件中,我有子类

class Extract(GUI):
    def __init__(self,window):
        super().__init__(window)
        ...
        self.plot.bind('<Button-1>',self.keyfile)

    def keyfile(self,event):
        ... #This function creates a file that's used to get data

if __name__ == '__main__':
    window = tk.Tk()
    gui = GUI(window)
    window.mainloop()
类提取(GUI): 定义初始化(自,窗口): 超级()。\uuuu初始化\uuuu(窗口) ... self.plot.bind(“”,self.keyfile) def密钥文件(自身、事件): ... #此函数用于创建用于获取数据的文件 如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu': window=tk.tk() gui=gui(窗口) window.mainloop() 我在这里看到了很多关于使用元类的内容,但是我仍然对它感到困惑,所以我想我应该在这里发布我的代码,但是还有其他方法可以让子类运行吗?超级阶级工作得很好