Opaque splash screen

7 views
Skip to first unread message

astan

unread,
Dec 11, 2009, 4:18:51 PM12/11/09
to wxPython-users
Hi,
I'm trying to make a splash screen that is somewhat opaque. Here is my
code snippet for the splash screen class:

class MySplashScreen(wx.SplashScreen):
def __init__(self,path):
bmp = wx.Bitmap(path)
img = bmp.ConvertToImage()
img.InitAlpha()
for y in range(img.GetHeight()):
for x in range(img.GetWidth()):
img.SetAlpha(x,y,255)
img.ConvertAlphaToMask(220)
bmp = img.ConvertToBitmap()
wx.SplashScreen.__init__(self, bmp,
wx.SPLASH_CENTRE_ON_SCREEN |
wx.SPLASH_TIMEOUT,
5000, None, -1)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.fc = wx.FutureCall(2000, self.ShowMain)

def OnClose(self, evt):
evt.Skip()
self.Hide()
if self.fc.IsRunning():
self.fc.Stop()
self.ShowMain()

The image/png that I'm trying to use doesn't have an alpha channel,
thats why I tried to set the alpha channel for it, but I don't know if
it is correct. Any ideas what I'm doing wrong? or if it was possible
or not?
Thanks for any help


def ShowMain(self):
if self.fc.IsRunning():
self.Raise()

Robin Dunn

unread,
Dec 11, 2009, 6:12:17 PM12/11/09
to wxpytho...@googlegroups.com
On 12/11/09 1:18 PM, astan wrote:

> The image/png that I'm trying to use doesn't have an alpha channel,
> thats why I tried to set the alpha channel for it, but I don't know if
> it is correct. Any ideas what I'm doing wrong? or if it was possible
> or not?

If all you want is a uniform level of transparency for the whole window
then you can just call the splash screen's SetTransparent method
(inherited from wx.Frame.)


--
Robin Dunn
Software Craftsman
http://wxPython.org

astan

unread,
Dec 16, 2009, 9:22:20 AM12/16/09
to wxPython-users
Thanks! This also worked. I didn't know I could do that.
Reply all
Reply to author
Forward
0 new messages