Splash screen positioning

Hey Robin,

Sorry it was a while before I responded to this. I believe I have the code in place to do what you suggested, but am still not having much luck. When my program launches, it hits my App class, which is:

class App(wx.App):
    def OnInit(self):
        frame = Frame()
        frame.Show()
        return True

Then Frame() is:

class Frame(wx.Frame):
    def __init__(self):
        # Set up the frame
        self.frame = wx.Frame.__init__(self, None, id = -1, title =
            "Domainspotter!", pos = (300, 200), size = (700, 600))
        # Show logo splash screen while things startup
        splashimg = wx.Image("resources/logo.png",
            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        wx.SplashScreen(splashimg, wx.SPLASH_CENTRE_ON_PARENT |
            wx.SPLASH_TIMEOUT, 2000, self.frame, -1)
        wx.Yield()

So I have wx.SPLASH_CENTRE_ON_PARENT set, and I have the parent set as self.frame, which should be my main frame that is shown. However, when I launch this, the splash is still centered on the screen, not on the frame. What else am I missing?

Thanks so much,
Sam

···

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

wormwood_3 wrote:

So would it be best to set "app" as the parent for SplashScreen, or instead move the splashscreen addition into my Frame class? Or something else? Going through the tutorials and the book, I have been a little unclear so far whether the best practice is to do setup things like splash screens, and welcome dialogs, etc in App or Frame.

It can't use the app as a parent since it is not a window. You can move
the creation of the frame into your OnInit, then after you create the
frame you create the splash, using the frame as the parent. Don't
forget to use the wx.SPLASH_CENTER_ON_PARENT style for the splash window.

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

I fixed your code:

import wx

class App(wx.App):
def OnInit(self):
frame = Frame()
frame.Show()
return True

class Frame(wx.Frame):
def init(self):

Set up the frame

   wx.Frame.__init__(self, None, id = -1, title = "Domainspotter!", pos = (300, 200), size = (700, 600))

Show logo splash screen while things startup

   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)
wx.Yield()

a = App()
a.MainLoop()

  • Roee.