Exemple #1
0
    def __init__(self,
                 parent,
                 parent2,
                 tbstyle,
                 windowstyle,
                 closingstyle,
                 scrollType=TB_SCR_TYPE_DU):
        """Default Class Constructor.

       Used Internally. Do Not Call Directly This Class In Your Application!
       """

        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          "window",
                          wx.DefaultPosition,
                          wx.DefaultSize,
                          style=windowstyle | wx.CLIP_CHILDREN)

        self._starttime = wx.GetLocalTime()
        self._parent2 = parent2
        self._parent = parent
        self._sleeptime = 10
        self._step = 4
        self._pausetime = 1700
        self._textcolour = wx.BLACK
        self._popuptext = "Change Me!"
        # the size we want the dialog to be
        framesize = wx.Size(150, 170)
        self._count = 1
        self._tbstyle = tbstyle
        self._windowstyle = windowstyle
        self._closingstyle = closingstyle
        self._scrollType = scrollType

        if tbstyle == TB_COMPLEX:
            self.sizer = wx.BoxSizer(wx.VERTICAL)
        else:
            self._staticbitmap = None

        if self._windowstyle == TB_CAPTION:
            self.Bind(wx.EVT_CLOSE, self.OnClose)
            self.SetTitle("")

        if self._closingstyle & TB_ONCLICK and self._windowstyle != TB_CAPTION:
            self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)

        self._bottomright = wx.Point(wx.GetDisplaySize().GetWidth(),
                                     wx.GetDisplaySize().GetHeight())

        self.SetDimensions(self._bottomright.x, self._bottomright.y,
                           framesize.GetWidth(), framesize.GetHeight())
Exemple #2
0
    def OnPaint(self, e):

        self.count += 1

        dc = PDC(self)
        gc = wx.GraphicsContext.Create(dc)

        gc.Scale(*([self.scale] * 2))
        path = gc.CreatePath()
        path.AddRectangle(0, 0, *self.Rect[2:])

        path2 = gc.CreatePath()

        for i in xrange(30):
            path2.AddRectangle(
                randint(0, 400),
                randint(0, 400),
                50,
                50,
            )

        gc.SetPen(wx.Pen(wx.Colour(0, 0, 128), 3))
        gc.SetBrush(
            gc.CreateLinearGradientBrush(0, 0, 100, 100, wx.GREEN, wx.BLUE))
        gc.DrawPath(path)

        gc.SetBrush(
            gc.CreateLinearGradientBrush(0, 0, 100, 100, wx.RED, wx.BLUE))
        gc.DrawPath(path2)

        for fs in xrange(30, 100, 10):
            font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
            font.SetPointSize(fs)
            gc.SetFont(
                font,
                wx.Colour(randint(0, 255), randint(0, 255), randint(0, 255)))
            gc.DrawRotatedText('hello digsby', 40, 80,
                               self.theta if fs % 20 == 0 else -self.theta)


#        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
#        font.SetPointSize(72)
#        gc.SetFont(font, wx.WHITE)
#        gc.DrawRotatedText('hello digsby', 40,80, self.theta)#, wx.TRANSPARENT_BRUSH)
        font.SetPointSize(15)
        gc.SetFont(font, wx.WHITE)
        gc.DrawText("FPS: " + str(self.FPS) + "/" + str(1000.0 / self.rr), 0,
                    0)
        gc.DrawText("Time: " + str(wx.GetLocalTime()), 0, 17)
        gc.DrawText("Process id: " + str(wx.GetProcessId()), 0, 34)
        gc.DrawText("OS: " + str(wx.GetOsDescription()), 0, 51)
Exemple #3
0
    def __init__(self,
                 parent,
                 parent2,
                 tbstyle,
                 windowstyle,
                 closingstyle,
                 scrollType=TB_SCR_TYPE_DU):
        """
        Default class constructor.
        Used internally. Do not call directly this class in your application!

        :param `parent`: the window parent;
        :param `parent2`: the L{ToasterBox} calling this window;
        :param `tbstyle`: the L{ToasterBoxWindow} main style. Can be one of the following
         bits:

         ====================== ======= ================================
         `ToasterBox` Style      Value  Description
         ====================== ======= ================================
         ``TB_SIMPLE``              0x1 A simple L{ToasterBox}, with background image and text customization can be created
         ``TB_COMPLEX``             0x2 `ToasterBoxes` with different degree of complexity can be created. You can add as many controls as you want, provided that you call the L{AddPanel} method and pass to it a dummy frame and a `wx.Panel`.
         ====================== ======= ================================

        :param `windowstyle`: this parameter influences the visual appearance of
         L{ToasterBoxWindow}, and can be one of the following styles:

         ====================== ========== ================================
         Window Style           Hex Value  Description
         ====================== ========== ================================
         ``TB_DEFAULT_STYLE``   0x2008002  Default window style for L{ToasterBox}, with no caption nor close box.
         ``TB_CAPTION``         0x22009806 L{ToasterBox} will have a caption, with the possibility to set a title for the L{ToasterBox} frame, and a close box.
         ====================== ========== ================================
       
        :param `closingstyle`: the closing style for L{ToasterBoxWindow}. Can be one of the
         following bits:

         ==================== =========== ==================================================
         Closing Styles       Hex Value   Description
         ==================== =========== ==================================================
         ``TB_ONTIME``                0x1 L{ToasterBox} will close after a specified amount of time.
         ``TB_ONCLICK``               0x2 L{ToasterBox} can be closed by clicking anywhere on the L{ToasterBox} frame.
         ==================== =========== ==================================================

        :param `scrollType`: the scrolling direction for L{ToasterBoxWindow}. Can be one of the
         following bits:

         ==================== =========== ==================================================
         Scroll Styles        Hex Value   Description
         ==================== =========== ==================================================
         ``TB_SCR_TYPE_UD``           0x1 L{ToasterBox} will scroll from up to down
         ``TB_SCR_TYPE_DU``           0x2 L{ToasterBox} will scroll from down to up
         ``TB_SCR_TYPE_FADE``         0x4 L{ToasterBox} will fade in/out (without scrolling).
         ==================== =========== ==================================================

        """

        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          "window",
                          wx.DefaultPosition,
                          wx.DefaultSize,
                          style=windowstyle | wx.CLIP_CHILDREN)

        self._starttime = wx.GetLocalTime()
        self._parent2 = parent2
        self._parent = parent
        self._sleeptime = 10
        self._step = 4
        self._pausetime = 1700
        self._textcolour = wx.BLACK
        self._popuptext = "Change Me!"
        # the size we want the dialog to be
        framesize = wx.Size(150, 170)
        self._count = 1
        self._tbstyle = tbstyle
        self._windowstyle = windowstyle
        self._closingstyle = closingstyle
        self._backgroundcolour = wx.WHITE

        if tbstyle == TB_COMPLEX:
            self.sizer = wx.BoxSizer(wx.VERTICAL)
        else:
            self._staticbitmap = None

        if self._windowstyle == TB_CAPTION:
            self.Bind(wx.EVT_CLOSE, self.OnClose)
            self.SetTitle("")

        if scrollType == TB_SCR_TYPE_FADE and not self.CanSetTransparent():
            import warnings
            warnings.warn(
                "The style ``TB_SCR_TYPE_FADE`` is not supported on this platform."
            )
            scrollType = TB_SCR_TYPE_DU

        self._scrollType = scrollType

        if self._closingstyle & TB_ONCLICK and self._windowstyle != TB_CAPTION:
            self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown)

        self._bottomright = wx.Point(wx.GetDisplaySize().GetWidth(),
                                     wx.GetDisplaySize().GetHeight())

        self.SetDimensions(self._bottomright.x, self._bottomright.y,
                           framesize.GetWidth(), framesize.GetHeight())

        self._scrollTimer = wx.Timer(self, -1)
        self._alphaTimer = wx.Timer(self, -1)

        self.Bind(wx.EVT_TIMER, self.OnScrollTimer, self._scrollTimer)
        self.Bind(wx.EVT_TIMER, self.AlphaCycle, self._alphaTimer)

        if not self._tbstyle & TB_COMPLEX:
            self.Bind(wx.EVT_PAINT, self.OnPaint)
            self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)