[wxPython-users] Setting a transparent region on a bitmap

David Poundall david.poundall at treatmentservices.co.uk
Wed Jan 2 14:24:18 PST 2008


Sorry Chris, full code as follows....

class SplashScreen(wx.Frame):
    """ Splash screen configured so that it destroys once the main 
    Console frame has instigated or if the timer times out."""   
 
    def __init__(self, bmp, timeout=10000):

        self.bmp = bmp
        pos=wx.DefaultPosition
        size=wx.DefaultSize
        style= wx.FRAME_SHAPED | wx.STAY_ON_TOP | wx.FRAME_NO_TASKBAR
        
        wx.Frame.__init__(self, None, -1, "", pos, size, style)
        
        mask = wx.Mask(self.bmp, wx.WHITE)
        self.bmp.SetMask(mask)        
        self.reg = wx.RegionFromBitmap(self.bmp)
        self.SetShape(self.reg)
        
        #Starts The Timer. Once Expired, AdvancedSplash Is Destroyed
        self._splashtimer = wx.PyTimer(self.Close)
        self._splashtimer.Start(timeout)

        # Set The AdvancedSplash Size To The Bitmap Size    
        w = self.bmp.GetWidth()
        h = self.bmp.GetHeight()
        self.SetSize((w, h))
     
        # Bind the close event and display the screen     
        self.Bind(wx.EVT_CLOSE, self.CloseTest)
        self.CenterOnScreen()
        self.Show()    
        
    def CloseTest(self,event):
        """ Closing
        """
        app.frConsole.Show()   
        event.Skip()


Note - Since the original post I have upgraded to Python 2.5 from 2.4.
can't get the full bitmap to display at all now.  Probably a red herring but
I mention it just in case.

I will try other forms of bitmap as per Andrea's class notes.  Will report
back.

- Thanks


> -----Original Message-----
> From: Christopher Barker [mailto:Chris.Barker at noaa.gov]
> Sent: 02 January 2008 19:51
> To: wxPython-users at lists.wxwidgets.org
> Subject: Re: [wxPython-users] Setting a transparent region on a bitmap
> 
> David Poundall wrote:
> > I am trying to get to grips with masking a bitmap and I am have a
> > problem.  Based on AG’s code I am running this in a frame …
> >
> >
> >
> >         mask = wx.Mask(self.bmp, wx.WHITE)
> >         self.bmp.SetMask(mask)
> >         self.reg = wx.RegionFromBitmap(self.bmp)
> >         self.SetShape(self.reg)
> >         self.Show()
> 
> Do try to make a complete, running sample, so we can try it out and know
> all of what you are trying to do, but:
> 
> I don't think you want self.SetShape(self.reg) -- that sets the "Shape"
> of the Window, so it will only draw within that shape. If you just set
> the mast and Show() you should be done, but it's hard to know without
> knowing what your Paint handler is doing.
> 
> 
> -Chris
> 
> 
> --
> Christopher Barker, Ph.D.
> Oceanographer
> 
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
> 
> Chris.Barker at noaa.gov
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.13/1206 - Release Date:
> 01/01/2008 12:09
> 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.17.13/1206 - Release Date: 01/01/2008
12:09
 




More information about the wxpython-users mailing list