Exemplo n.º 1
0
    def __init__(self,
                 parent,
                 ID=-1,
                 title="SplashScreen",
                 style=wx.SIMPLE_BORDER | wx.STAY_ON_TOP,
                 duration=1500,
                 bitmapfile="bitmaps/splashscreen.bmp",
                 callback=None):
        '''
        parent, ID, title, style -- see wx.Frame
        duration -- milliseconds to display the splash screen
        bitmapfile -- absolute or relative pathname to image file
        callback -- if specified, is called when timer completes, callback is
                    responsible for closing the splash screen
        '''
        ### Loading bitmap
        self.bitmap = bmp = wx.Image(bitmapfile,
                                     wx.BITMAP_TYPE_ANY).ConvertToBitmap()

        ### Determine size of bitmap to size window...
        size = (bmp.GetWidth(), bmp.GetHeight())

        # size of screen
        width = wx.SystemSettings_GetMetric(wx.SYS_SCREEN_X)
        height = wx.SystemSettings_GetMetric(wx.SYS_SCREEN_Y)
        pos = ((width - size[0]) / 2, (height - size[1]) / 2)

        # check for overflow...
        if pos[0] < 0:
            size = (wx.SystemSettings_GetSystemMetric(wx.SYS_SCREEN_X),
                    size[1])
        if pos[1] < 0:
            size = (size[0],
                    wx.SystemSettings_GetSystemMetric(wx.SYS_SCREEN_Y))

        wx.Frame.__init__(self, parent, ID, title, pos, size, style)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBG)

        self.Show(True)

        class SplashTimer(wx.Timer):
            def __init__(self, targetFunction):
                self.Notify = targetFunction
                wx.Timer.__init__(self)

        if callback is None:
            callback = self.OnSplashExitDefault

        self.timer = SplashTimer(callback)
        self.timer.Start(duration, 1)  # one-shot only
Exemplo n.º 2
0
    def __init__(self,
                 parent,
                 ID=-1,
                 title="",
                 style=wx.SIMPLE_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP,
                 duration=1000,
                 bitmapfile=""):

        ### Loading bitmap
        self.bitmap = bmp = wx.Image(bitmapfile,
                                     wx.BITMAP_TYPE_ANY).ConvertToBitmap()

        ### Determine size of bitmap to size window...
        size = (bmp.GetWidth(), bmp.GetHeight())
        self.textfont = wx.Font(1, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
                                "Arial")
        self.textpos = (0, 0)
        self.textcolor = wx.BLACK
        self.text1 = ""
        self.text2 = ""
        self.textsize = 10.0
        self.textfont.SetPointSize(self.textsize)

        # size of screen
        width = wx.SystemSettings_GetMetric(wx.SYS_SCREEN_X)
        height = wx.SystemSettings_GetMetric(wx.SYS_SCREEN_Y)
        pos = ((width - size[0]) / 2, (height - size[1]) / 2)

        # check for overflow...
        if pos[0] < 0:
            size = (wx.SystemSettings_GetSystemMetric(wx.SYS_SCREEN_X),
                    size[1])
        if pos[1] < 0:
            size = (size[0],
                    wx.SystemSettings_GetSystemMetric(wx.SYS_SCREEN_Y))

        # Setting Initial Properties
        wx.Frame.__init__(self, parent, ID, title, pos, size, style)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBG)

        self.Show(True)
Exemplo n.º 3
0
    def __init__(self,
                 parent,
                 ID=-1,
                 title="SplashScreen",
                 style=wx.SIMPLE_BORDER | wx.STAY_ON_TOP | wx.FRAME_SHAPED
                 | wx.FRAME_NO_TASKBAR,
                 duration=1500,
                 bitmapfile="geosings.png",
                 callback=None):
        '''
        parent, ID, title, style -- see wx.Frame
        duration -- milliseconds to display the splash screen
        bitmapfile -- absolute or relative pathname to image file
        callback -- if specified, is called when timer completes, callback is
                    responsible for closing the splash screen
        '''
        ### Loading bitmap
        if type(bitmapfile)==str or \
            type(bitmapfile)==unicode:
            self.bitmap = bmp = wx.Image(bitmapfile,
                                         wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        else:
            self.bitmap = bmp = bitmapfile

        ### Determine size of bitmap to size window...
        size = (bmp.GetWidth(), bmp.GetHeight())
        #self.hasShape = False

        # size of screen
        width = wx.SystemSettings_GetMetric(wx.SYS_SCREEN_X)
        height = wx.SystemSettings_GetMetric(wx.SYS_SCREEN_Y)
        pos = ((width - size[0]) / 2, (height - size[1]) / 2)

        # check for overflow...
        if pos[0] < 0:
            size = (wx.SystemSettings_GetSystemMetric(wx.SYS_SCREEN_X),
                    size[1])
        if pos[1] < 0:
            size = (size[0],
                    wx.SystemSettings_GetSystemMetric(wx.SYS_SCREEN_Y))

        wx.Frame.__init__(self, parent, ID, title, pos, size, style)

        if wx.Platform == "__WXGTK__":
            # wxGTK requires that the window be created before you can
            # set its shape, so delay the call to SetWindowShape until
            # this event.
            self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape)
        else:
            # On wxMSW and wxMac the window has already been created, so go for it.
            self.SetWindowShape()

        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseClick)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBG)

        self.Show(True)

        class SplashTimer(wx.Timer):
            def __init__(self, targetFunction):
                self.Notify = targetFunction
                wx.Timer.__init__(self)

        if callback is None:
            callback = self.OnSplashExitDefault

        self.timer = SplashTimer(callback)
        self.timer.Start(duration, 1)  # one-shot only