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