我有一个非常简单的GUI,它接受两个参数,然后调用名为DigitalFilter(),BeatByBeatVariables()和GetSummaryOfWholeTest()的其他三个类。这是我第一次写课程,我需要语法帮助。使用wxpython进行GUI的类继承
具体来说,你能帮我继承吗?我想要在应用程序启动时调用GUI的类MainWindow(wx.Frame)。然后,当用户在GUI中单击self.button时,我希望应用程序首先运行myFilter = DigitalFilter(TestID,FilterTimePeriod),然后再运行myBeatByBeat = BeatByBeatVariables(arg1,arg2),最后运行myTestSummary = GetSummaryOfWholeTest argA,argB)
请注意,myBeatByBeat无法开始运行,直到myFilter完成创建,因为myFilter的实例化会创建作为myBeatByBeat输入所需的csv文件。同样,myTest摘要无法开始运行,直到myBeatByBeat完成创建,因为myBeatByBeat的实例化会创建作为myTestSummary输入所需的csv文件。
任何人都可以向我展示使用适当的继承编写/实例化这些类的正确语法,以便每个类的工作都将按照尊重其输入/输出关系的顺序完成。
我假设在这里应该继承,但我不知道应该从什么继承。我也不知道我是否没有看到其他必要的概念来为代码提供必要的相互关系。
下面是相关代码的概要:
class DigitalFilter():
def __init__(self,TestID,FilterTimePeriod):
# All the code for the digital filter goes here.
# I am omitting this class' code for simplicity.
class BeatByBeatVariables():
def __init__(self,arg1,arg2):
# I am omitting this class' code for simplicity
class GetSummaryOfWholeTest():
def __init__(self,argA,ArgB):
# This class' code is omitted for simplicity
class MainWindow(wx.Frame):
def __init__(self, parent,id,title):
wx.Frame.__init__(self,parent,wx.ID_ANY,title, size = (500,500), style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
# Create self.editname and self.edithear in code that I am omitting for simplicity
self.button =wx.Button(self, label="Click here to filter the data", pos=(200, 125))
self.Bind(wx.EVT_BUTTON, self.OnClick,self.button)
def OnClick(self,event):
FilterTimePeriod = self.editname.GetValue()
TestID = self.edithear.GetValue()
myFilter=DigitalFilter(TestID,FilterTimePeriod)
myBeatByBeat = BeatByBeatVariables(arg1,arg2)
myTestSummary = GetSummaryOfWholeTest(argA,argB)
app = wx.PySimpleApp()
frame = MainWindow(None,-1,"Filtering Software. Version 1.0")
app.MainLoop()
注:我使用Python 2.6,因为我也使用numpy的和sciepy