2010-10-05 81 views
1

我一直在試圖沒有成功地控制一個類內的對象,而沒有這樣的類。這些是重要的位(不是全部!)關於類的新手混淆

def GOGO():     ################################################ 
    VFrame.SetStatusText("Ok") # ----> THIS IS WHAT I AM TRYING TO FIX  # 
           # ----> I have tried all sorts of combinations # 
           # ----> and I still can't change this property # 
           ################################################ 
           # How do I fix this? What am I doing wrong??? # 
           ################################################ 
class VFrame(wx.Frame): 
    def __init__(self, parent): 
     wx.Frame.__init__(self, parent, -1, _("Glob"), 
          size=(1024, 768), style=wx.DEFAULT_FRAME_STYLE) 
     self.SetStatusText("Ready - Disconnected from Database.") 

class MySplashScreen(wx.SplashScreen): 
    def __init__(self, parent=None): 
     aBitmap = wx.Image(name=img_splash).ConvertToBitmap() 
     splashStyle = wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT 
     splashDuration = 50 
     wx.SplashScreen.__init__(self, aBitmap, splashStyle, splashDuration, parent) 
     self.Bind(wx.EVT_CLOSE, self.CloseSplash) 
     wx.Yield() 
    def CloseSplash(self, evt): 
     self.Hide() 
     frame = VFrame(parent=None) 
     app.SetTopWindow(frame) 
     frame.Show(True) 
     evt.Skip() 

class MyApp(wx.App): 
    def OnInit(self): 
     MySplash = MySplashScreen() 
     MySplash.Show() 
     return True 

if __name__ == '__main__': 
    app = MyApp() 
    app.MainLoop() 
+0

你會得到什麼錯誤? – katrielalex 2010-10-05 21:57:32

回答

1

您需要實例化您的VFrame類。

frame = VFrame(parent) 
frame.SetStatusText("OK") 

這是

frame = VFrame(parent) 
VFrame.SetStatusText(frame, "OK") 

從本質上講,你要告訴你,你要設置的VFrame的狀態文本的電腦大多是語法糖。

+0

爲了解決這個問題,除了你的建議之外,我在def CloseSplash中引入了「全局框架」。 – relima 2010-10-05 22:04:47