wxSplashScreen not timing out with GTK

Hi,

One thing that has been bothering me for a while is that wxSplashScreen
doesn't time out when I'm using Linux, but it does at Windows systems.

My code is ('stolen' from the demo):

···

======================================================================
#!/usr/bin/python
# -*- encoding: iso-8859-1 -*-

import os
import sys

from bibpathfix import *

import wx
from wxPython import wx

work_path = os.path.dirname(sys.argv[0])
if work_path:
    os.chdir(work_path)

######################################################################
class StartupApp(wx.wxApp):
    """Startup application used to present the splash screen"""

    def OnInit(self):

        global imagens
        global principal

        wx.wxInitAllImageHandlers()

        splashfile = os.path.sep.join([imagens, 'BH_SysB.png'])
        bmp = wx.wxImage(splashfile).ConvertToBitmap()
        splash = wx.wxSplashScreen(bmp,
                                   wx.wxSPLASH_CENTRE_ON_SCREEN |
                                   wx.wxSPLASH_TIMEOUT,
                                   2000, None, -1,
                                   style = wx.wxSIMPLE_BORDER |
                                           wx.wxFRAME_NO_TASKBAR |
                                           wx.wxSTAY_ON_TOP)

        import principal

        # OnInit should return a boolean value...
        return True

if __name__ == "__main__":
    app = StartupApp(0)
    app.MainLoop()
    
    # After the time out, call our app.
    principal.main()

Another informaton that might help is that when there's focus on the
xterm where I called the app, the timing out works. If I call the app
from an icon on the desktop, I have to pass the mouse over the
splashscreen (I don't need to click or anything) to make it disappear.
I think that it is timing out but it isn't being dismissed without
focus.

Anyone has seen that? Any hints on what I might do to make it work with
GTK as it works with Linux? I'm using KDE with the 'focus follows
mouse' option for focus.

Be seeing you,
--
Godoy. <godoy@ieee.org>

Jorge Godoy wrote:

Hi,

One thing that has been bothering me for a while is that wxSplashScreen
doesn't time out when I'm using Linux, but it does at Windows systems.

My code is ('stolen' from the demo):

Not quite, since the timeout does work on Linux in the demo.

if __name__ == "__main__":
    app = StartupApp(0)
    app.MainLoop()
        # After the time out, call our app.
    principal.main()

You would be better off to stay in the MainLoop and create your other applicaiton windows and such from the splashscreen's EVT_CLOSE handler like the demo does. There should really be only one App and MainLoop per process.

Another informaton that might help is that when there's focus on the
xterm where I called the app, the timing out works. If I call the app
from an icon on the desktop, I have to pass the mouse over the
splashscreen (I don't need to click or anything) to make it disappear.
I think that it is timing out but it isn't being dismissed without
focus.

This usually means that something is waiting for some idle events to finish processing. (wxGTK does a number of optimizations internally by waiting for idle time to do some things.) Since you don't do anything that would cause other events to happen (like creating a new Frame) then there is no new idle events (because they only happen when the event queue *becomes* empty) so the splash screen window is never fully destroyed.

···

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

Robin Dunn <robin@alldunn.com> writes:

Jorge Godoy wrote:

Hi,
One thing that has been bothering me for a while is that
wxSplashScreen
doesn't time out when I'm using Linux, but it does at Windows systems.
My code is ('stolen' from the demo):

Not quite, since the timeout does work on Linux in the demo.

Yep. :slight_smile: This is what bothered me. And until writing that previous
message I hadn't noticed that there was such a difference (you also
mention that below).

if __name__ == "__main__":
    app = StartupApp(0)
    app.MainLoop()
        # After the time out, call our app.
    principal.main()

You would be better off to stay in the MainLoop and create your other
applicaiton windows and such from the splashscreen's EVT_CLOSE handler
like the demo does. There should really be only one App and MainLoop
per process.

(Here it is!)

I'll try doing that... Lets play with splash screens this Sunday :wink:

This usually means that something is waiting for some idle events to
finish processing. (wxGTK does a number of optimizations internally by
waiting for idle time to do some things.) Since you don't do anything
that would cause other events to happen (like creating a new Frame) then
there is no new idle events (because they only happen when the event
queue *becomes* empty) so the splash screen window is never fully
destroyed.

I see... Probably because I have the call to the application outside
its classe. I'll give you feedback on that. Thanks for your attention
and patience. :wink:

···

--
Godoy. <godoy@ieee.org>

Robin Dunn <robin@alldunn.com> writes:

This usually means that something is waiting for some idle events to
finish processing. (wxGTK does a number of optimizations internally by
waiting for idle time to do some things.) Since you don't do anything
that would cause other events to happen (like creating a new Frame) then
there is no new idle events (because they only happen when the event
queue *becomes* empty) so the splash screen window is never fully
destroyed.

There were two problems:

1. What you described above
2. I was not calling the SplashScreen.__init__ method, but instead
   instantiating it.

When I fixed the two things above, it worked perfectly on both OSs.

···

======================================================================
#!/usr/bin/python
# -*- encoding: iso-8859-1 -*-

import os
import sys

from bibpathfix import *

import wx
from wxPython import wx

work_path = os.path.dirname(sys.argv[0])
if work_path:
    os.chdir(work_path)

###
class SplashScreenBHSys(wx.wxSplashScreen):
    def __init__(self):

        global imagens

        wx.wxInitAllImageHandlers()

        splashfile = os.path.sep.join([imagens, 'BH_SysB.png'])
        bmp = wx.wxImage(splashfile).ConvertToBitmap()
        splash = wx.wxSplashScreen.__init__(self, bmp,
                                            wx.wxSPLASH_CENTRE_ON_SCREEN |
                                            wx.wxSPLASH_TIMEOUT,
                                            3000, None, -1,
                                            style = wx.wxSIMPLE_BORDER |
                                                    wx.wxFRAME_NO_TASKBAR |
                                                    wx.wxSTAY_ON_TOP)

        wx.EVT_CLOSE(self, self.OnClose)

    def OnClose(self, event):
        import principal

        app = principal.MyMainApp(None, -1, "")
        app.Show()

        event.Skip()

###
class StartupApp(wx.wxApp):
    """Startup application used to present the splash screen"""

    def OnInit(self):
        wx.wxInitAllImageHandlers()
        splash = SplashScreenBHSys()
        splash.Show()
        return True

if __name__ == "__main__":
    app = StartupApp(0)
    app.MainLoop()

Thanks,
--
Godoy. <godoy@ieee.org>