我有一個非常簡單的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