Splash screen positioning

I moved the SplashScreen up to the Frame class (still not sure if that is right). Then I tried setting the parent to self:

class Frame(wx.Frame):
    def __init__(self):
        print "Domainspotter starting up..."
        # Show logo splash screen while things are setup
        splashimg = wx.Image("resources/logo.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        wx.SplashScreen(splashimg, wx.SPLASH_CENTRE_ON_PARENT | wx.SPLASH_TIMEOUT,
            2000, self, -1)

But I get:

TypeError: argument number 4: a 'wxWindow *' is expected, 'Frame' is received

Should I not have this function in Frame or App??

Thanks,
Sam

···

__________________________________
----- Original Message ----
From: Robin Dunn <robin@alldunn.com>
To: wxPython-users@lists.wxwidgets.org
Sent: Wednesday, September 26, 2007 12:51:12 PM
Subject: Re: [wxPython-users] Splash screen positioning

wormwood_3 wrote:

Hi all,

I want to show a splash screen when my application opens, and I would like it to be centered over the parent frame. I added the following code:

class App(wx.App):
    """
    Main application.
    """
    def OnInit(self):
        splashimg = wx.Image("resources/logo.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        wx.SplashScreen(splashimg, wx.SPLASH_CENTRE_ON_PARENT | wx.SPLASH_TIMEOUT,
            2000, None, -1)
        wx.Yield()
        return True

The image shows fine, but it is centered on screen, not on the parent. While writing this I realized this is likely due to the fact that I have parent set as "None"! However, I am not sure what the parent needs to be. When the script runs it first hits:

if __name__ == '__main__':
     app = App()
     frame = Frame()
     frame.Show()
     print "Awaiting your commands."
     app.MainLoop()

So I tried setting parent for the SplashScreen to "frame", as that is the instance of my main frame, but I get:

NameError: global name 'frame' is not defined

Not quite sure if I should put the splash somewhere else, or how to get the right parent.

Chicken and egg problem: You are creating the splash in the app's
OnInit, which is called from within the app's __init__, so the line
"frame = Frame()" hasn't yet been executed.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

wormwood_3 wrote:

I moved the SplashScreen up to the Frame class (still not sure if that is right). Then I tried setting the parent to self:

class Frame(wx.Frame):
    def __init__(self):
        print "Domainspotter starting up..." # Show logo splash screen while things are setup
        splashimg = wx.Image("resources/logo.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        wx.SplashScreen(splashimg, wx.SPLASH_CENTRE_ON_PARENT | wx.SPLASH_TIMEOUT, 2000, self, -1)

But I get:

TypeError: argument number 4: a 'wxWindow *' is expected, 'Frame' is received

The problem here is that you have not yet called wx.Frame.__init__ so the C++ wrappers do not know the C++ type of the object yet.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!