AdvancedSplash problems

I'm trying to integrate Andrea Gavana's AdvancedSplash into Dabo. For my testing, I created a simple .png graphic of the letters 'dabo', with the background transparent.

  The problem is that on all platforms, the Paint code fires, but doesn't visibly affect the splashscreen until all the other activities have completed. As an example, I recorded a short screencast that shows the opening of the Dabo Designer, which involves lots of initialization code and the creation of several complex windows. Note that the shaped splash screen appears right away, but is blank. The colors from the bitmap don't appear until after all of the other windows have completed their initialization.

  I've tried placing Refresh(), Update(), wx.SafeYield(), wx.CallAfter(), etc., in various places in the process, yet the bitmap is never displayed on the window until all other processing is complete. Is there any way to absolutely force the repaint?

  The screencast example is: <http://leafe.com/screencasts/splash.html>.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

Ed Leafe wrote:

    I'm trying to integrate Andrea Gavana's AdvancedSplash into Dabo. For my testing, I created a simple .png graphic of the letters 'dabo', with the background transparent.

    The problem is that on all platforms, the Paint code fires, but doesn't visibly affect the splashscreen until all the other activities have completed. As an example, I recorded a short screencast that shows the opening of the Dabo Designer, which involves lots of initialization code and the creation of several complex windows. Note that the shaped splash screen appears right away, but is blank. The colors from the bitmap don't appear until after all of the other windows have completed their initialization.

    I've tried placing Refresh(), Update(), wx.SafeYield(), wx.CallAfter (), etc., in various places in the process, yet the bitmap is never displayed on the window until all other processing is complete. Is there any way to absolutely force the repaint?

I assume all of this initialization is happening in OnInit? You could move it all to another function, say AfterInit, keeping just the splash screen stuff in OnInt. Then call AfterInit using wx.CallAfter. I'm not sure that would work, but it's worth a short if you haven't tried it already.

-tim

···

    The screencast example is: <Oops!.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

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

Yep. Right now I pass a callback function to the constructor, and the code in OnInit calls it with wx.CallAfter.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Feb 10, 2006, at 2:42 PM, Tim Hochberg wrote:

I assume all of this initialization is happening in OnInit? You could move it all to another function, say AfterInit, keeping just the splash screen stuff in OnInt. Then call AfterInit using wx.CallAfter. I'm not sure that would work, but it's worth a short if you haven't tried it already.

Hello Ed,

I'm trying to integrate Andrea Gavana's AdvancedSplash into Dabo.
For my testing, I created a simple .png graphic of the letters
'dabo', with the background transparent.

It's quite a long time that I do not look at the source code of
AdvancedSplash, but I am happy to look at it again :wink:

The screencast example is: <Oops!.

Very nice screencast, as usual :slight_smile:

The problem is that on all platforms, the Paint code fires, but
doesn't visibly affect the splashscreen until all the other
activities have completed. As an example, I recorded a short
screencast that shows the opening of the Dabo Designer, which
involves lots of initialization code and the creation of several
complex windows. Note that the shaped splash screen appears right
away, but is blank. The colors from the bitmap don't appear until
after all of the other windows have completed their initialization.

Mhm... it would be nice for me to have a way to reproduce the problem (i.e.
run a similar script as yours). I know AdvancedSplash is not so complicated,
so I am sure you can sort it out without my (quite often stupid :wink: )
suggestions. However, if you have a way to send the code (or a similar one
that reproduce the problem) I can try to take a look at it. 4 eyes are
always better than 2;-)

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77

You could always download the latest Dabo from our Subversion repository. :wink:

  The code is a little more complex than a typical wxPython app, since we have our Dabo application object, which creates our uiApp object, which for wx is an instance of wx.App. But the Dabo app object executes the following:

self.uiApp = dabo.ui.uiApp(self, callback=self.initUIApp)

  The UI app (wx.App) stores the dabo app reference and callback, and then its OnInit() reads:

def OnInit(self):
     app = self.dApp
     if app.showSplashScreen:
         splash = SplashScreen(app.splashImage, app.splashMaskColor,
                 app.splashTimeout)
         splash.Show()
     wx.CallAfter(self.callback)
     return True

  I'm including the code for the SplashScreen class after my sig - it should look pretty familiar to you. :wink:

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

class SplashScreen(wx.Frame):
     """This is a specialized form that is meant to be used as a startup
     splash screen. It takes an image file, bitmap, icon, etc., which is used
     to size and shape the form. If you specify a mask color, that color
     will be masked in the bitmap to appear transparent, and will affect the
     shape of the form.

     You may also pass a 'timeout' value; this is in milliseconds, and determines
     how long until the splash screen automatically closes. If you pass zero
     (or don't pass anything), the screen will remain visible until the user
     clicks on it.

     Many thanks to Andrea Gavana, whose 'AdvancedSplash' class was a
     huge inspiration (and source of code!) for this Dabo class. I also borrowed
     some ideas/code from the wxPython demo by Robin Dunn.
     """
     def __init__(self, bitmap=None, maskColor=None, timeout=0):
         style = wx.FRAME_NO_TASKBAR | wx.FRAME_SHAPED | wx.STAY_ON_TOP
         wx.Frame.__init__(self, None, -1, style=style)

         if isinstance(bitmap, basestring):
             # Convert it
             self._bmp = dabo.ui.pathToBmp(bitmap)
         else:
             self._bmp = bitmap

         if maskColor is not None:
             if isinstance(maskColor, basestring):
                 maskColor = dabo.dColors.colorTupleFromName(maskColor)
             self._bmp.SetMask(wx.Mask(self._bmp, maskColor))

         if wx.Platform == "__WXGTK__":
             self.Bind(wx.EVT_WINDOW_CREATE, self.setSizeAndShape)
         else:
             self.setSizeAndShape()

         self.setSizeAndShape()

         self.Bind(wx.EVT_MOUSE_EVENTS, self._onMouseEvents)
         self.Bind(wx.EVT_PAINT, self._onPaint)
         if timeout > 0:
             self.fc = wx.FutureCall(timeout, self._onTimer)

     def setSizeAndShape(self, evt=None):
         w = self._bmp.GetWidth()
         h = self._bmp.GetHeight()
         self.SetSize((w, h))
         self.SetBackgroundColour(wx.WHITE)
         reg = wx.RegionFromBitmap(self._bmp)
         self.SetShape(reg)
         self.CenterOnScreen()
         self.Refresh()
         if evt is not None:
             evt.Skip()

     def _onMouseEvents(self, evt):
         if evt.LeftDown() or evt.RightDown():
             self._disappear()
         evt.Skip()

     def _onTimer(self):
         self._disappear()

     def _disappear(self):
         try:
             self.fc.Stop()
         except:
             pass
         self.Close()

     def _onPaint(self, evt):
         dc = wx.PaintDC(self)
         dc.DrawBitmap(self._bmp, 0, 0, False)

         # I plan on adding support for a text string to be
         # displayed. This is Andrea's code, which I may use as
         # the basis for this.
# textcolour = self.GetTextColour()
# textfont = self.GetTextFont()
# textpos = self.GetTextPosition()
# text = self.GetText()
# dc.SetFont(textfont[0])
# dc.SetTextForeground(textcolour)
# dc.DrawText(text, textpos[0], textpos[1])

         # Seems like this only helps on OS X.
         if wx.Platform == "__WXMAC__":
             wx.SafeYield(self, True)
         evt.Skip()

···

On Feb 10, 2006, at 3:28 PM, Andrea Gavana wrote:

Mhm... it would be nice for me to have a way to reproduce the problem (i.e.
run a similar script as yours). I know AdvancedSplash is not so complicated,
so I am sure you can sort it out without my (quite often stupid :wink: )
suggestions. However, if you have a way to send the code (or a similar one
that reproduce the problem) I can try to take a look at it. 4 eyes are
always better than 2;-)

Hi Ed. I am on Mac and had similar trouble. Are you on Mac too?
I ended up rolling my own using old splashscreen code in lib folder of distribution as a starting point as Robin had suggested. You could also work with shaped frame from demo app. They both subclass Frame.

With these as a starting point, I was able to create a class and paint just fine on initialization. I am giving the splashscreen a destroy just after I do the main_frame.Show() in interim for it to disappear afterwards. The original splashscreen code in lib used a callback but was unable to have it work properly (will be still trying some things when I get a bit more time).

OnPaint does intial painting on frame and I am using a ScreenDC to repaint afterwards in an update method. I am still experimenting with ClientDC and ScreenDC as I have experienced some unexpected things on Mac, perhaps due to buffering (see earlier posts this week). My opinion is it seems the behavior of the DC is somewhat guided by the platform. I really only have the experience of a couple of days with DC so cannot be sure. I have still to test my results on Windows.

Regards,
David

Ed Leafe wrote:

···

    I'm trying to integrate Andrea Gavana's AdvancedSplash into Dabo. For my testing, I created a simple .png graphic of the letters 'dabo', with the background transparent.

    The problem is that on all platforms, the Paint code fires, but doesn't visibly affect the splashscreen until all the other activities have completed. As an example, I recorded a short screencast that shows the opening of the Dabo Designer, which involves lots of initialization code and the creation of several complex windows. Note that the shaped splash screen appears right away, but is blank. The colors from the bitmap don't appear until after all of the other windows have completed their initialization.

    I've tried placing Refresh(), Update(), wx.SafeYield(), wx.CallAfter (), etc., in various places in the process, yet the bitmap is never displayed on the window until all other processing is complete. Is there any way to absolutely force the repaint?

    The screencast example is: <Oops!.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

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

Hello Ed,

    I have just downloaded the Dabo SVN, but either I am mising something or
there is something missing :wink: :

The UI app (wx.App) stores the dabo app reference and callback, and
then its OnInit() reads:

def OnInit(self):
     app = self.dApp
     if app.showSplashScreen:
         splash = SplashScreen(app.splashImage, app.splashMaskColor,
                 app.splashTimeout)
         splash.Show()
     wx.CallAfter(self.callback)
     return True

Mhm... there is no wx.CallAfter(self.callback) in the SVN version I
checked...

I am surely missing something.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77

No, that's my fault. I have been playing around with the code so much that I only commit it when I'm sure it doesn't crash on any platform. That code was from last night, after I fixed a Gtk crash.

  Let me clean up the current code and test it, and then I'll commit that. I've been playing around with all sorts of DC variations, so things are a bit messy right now.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Feb 10, 2006, at 4:43 PM, Andrea Gavana wrote:

Mhm... there is no wx.CallAfter(self.callback) in the SVN version I
checked...

I am surely missing something.

Wait - I think I got it. Using a wx.BufferedPaintDC instead of a wx.PaintDC seems to do the trick. Let me test a bit more...

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Feb 10, 2006, at 4:52 PM, Ed Leafe wrote:

  Let me clean up the current code and test it, and then I'll commit that. I've been playing around with all sorts of DC variations, so things are a bit messy right now.

OK, I've just committed the changes. Looks much better on OS X, but now Windows looks like the Mac example did, and Gtk is still ugly. <sigh>

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Feb 10, 2006, at 4:43 PM, Andrea Gavana wrote:

Mhm... there is no wx.CallAfter(self.callback) in the SVN version I
checked...

I am surely missing something.

Hi Ed. I think you are experiencing some similar frustration to what I was having this week with DC. I will also be trying more things. It will be interesting to see what will be needed to repaint consistently across the three platforms after original paint. I am going to test what I have done on Windows tonight some time and give another go with ClientDC. I'll let you know how it worked out.

Regards,
David

Ed Leafe wrote:

···

    OK, I've just committed the changes. Looks much better on OS X, but now Windows looks like the Mac example did, and Gtk is still ugly. <sigh>