Convert Splashscreen to Modal window

Joined
Oct 19, 2010
Messages
1
Reaction score
0
Hello all,

I am trying to revamp my please wait window which appears while information for the next wxpython window is loading. Right now I have a splashscreen that appears in between window loads. However, the parent windows can be clicked while this is loading which is causing a crash of the application sometimes. I'd like to convert this to a modal window that displays an animated gif.

Here is the code I have for the splash screen:
Code:
import wx
from wx import ImageFromStream, BitmapFromImage
import cStringIO, zlib

class MySplashScreen(wx.SplashScreen):
    """
Create a splash screen widget.
    """
    def __init__(self, parent):
        # This is a recipe to a the screen.
        # Modify the following variables as necessary.
        aBitmap = self.getBitmap()
        splashStyle = wx.SPLASH_CENTRE_ON_PARENT | wx.SPLASH_TIMEOUT
        # milliseconds
        splashDuration = 100000
        # Call the constructor with the above arguments in exactly the
        # following order.
        wx.SplashScreen.__init__(self, aBitmap, splashStyle,
                                 splashDuration, parent)
        #self.Bind(wx.EVT_CLOSE, self.OnExit)

        wx.Yield()

    def getBitmap(self):
        return BitmapFromImage(self.getImage())
    
    def getImage(self):
        stream = cStringIO.StringIO(self.getData())
        return ImageFromStream(stream)
    
    def getData(self):
        return zlib.decompress(
'x\xda\x01\x83!|\xde\x89PNG...cannot show the rest of this image' )

class Busy(wx.Frame):
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.STAY_ON_TOP|wx.NO_BORDER
        wx.Frame.__init__(self, *args, **kwds)
        self.bitmap_1 = wx.StaticBitmap(self, -1, self.getBitmap())

        
        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("frame_1")
        self.SetSize((112, 80))
        self.SetBackgroundColour(wx.Colour(161, 189, 213))
        self.bitmap_1.SetMinSize((112,80))
        self.CenterOnScreen()
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_1.Add(self.bitmap_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
        self.SetAutoLayout(True)
        self.SetSizer(sizer_1)
        self.Layout()
        
        # end wxGlade

    
    
    def getBitmap(self):
        return BitmapFromImage(self.getImage())
    
    def getImage(self):
        stream = cStringIO.StringIO(self.getData())
        return ImageFromStream(stream)



# end of class MyFrame


class MyApp(wx.App):
    def OnInit(self):
        wx.InitAllImageHandlers()
        MySplash = MySplashScreen()
        MySplash.Show()
        return 1

# end of class MyApp

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

This is how its called:

Code:
busyAnim = busy.MySplashScreen(self)
            busyAnim.Show()
            import addUser
            if DEBUG:
                try:
                    import py_compile
                    py_compile.compile("moduleslib/addUser.py")
                    reload(addUser)
                except:
                    pass
            addUser.DEBUG = DEBUG
            AddUserWin = addUser.MyFrame(self, -1, "")
            AddUserWin.filldata(self.userID)
            busyAnim.Close()


So, to re-cap. I need to convert the splash screen to a modal window. When I tried to convert it to one. It would just show the modal window and would not go away when I was done loading the addUser window in the background.

I'm currently using wxPython 2.6.

Any help would be appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top