开发者

Newbie Confusion regarding classes

I have been trying, without success, to control an object within a class from without such class. These开发者_运维知识库 are the important bits (not the whole thing!)

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()


You need to instantiate your VFrame class.

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

This is mostly syntactic sugar for

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

Essentially, you have to tell the computer which VFrame's status text you want to set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜