0
我正在爲GUI使用wxPython編寫一個計算器。我做了一個名爲display的類來使用StaticText來顯示文本。無論如何,當我嘗試更新屏幕時,會引發異常。 下面的代碼:爲什麼我無法更新wxPython的StaticText?
class display:
def __init__(self,parent, id):
print "display class is working"
global string1
self.view = wx.StaticText(frame, -1, "Waiting", (30,7), style = wx.ALIGN_CENTRE)
@staticmethod
def update(self):
global string1
self.view.SetLabel(string1)
每當我嘗試運行update()函數,它會引發此異常:
AttributeError: 'function' object has no attribute 'view'
當我寫 「self.view = WX等等等等」,我試圖將StaticText設置爲變量名,所以我可以使用SetLabel函數。文本似乎工作,直到我嘗試更新它。爲什麼我不能更新它?我如何解決它?