def __init__(self, parent, text=''):
        ## super(AboutWindow, self).__init__(parent, style=wx.BORDER_SIMPLE)
        wx.Window.__init__(self, parent, style=wx.BORDER_SIMPLE)

        self.font = font = self.GetFont()
        self.font = font = wx.Font(42, wx.FONTFAMILY_DEFAULT,
                                   wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,
                                   False)
        self.SetFont(font)

        self.timer = wx.Timer(self, wx.ID_ANY)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.text = text

        self.step = 0
        self.speed = 42  # why not lol
        wx.CallAfter(self.StartTimer)

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)

        self.bmp = wx.Bitmap('EmbroidePyLogo.png')
        if PHOENIX:
            self.bmpBrush = wx.Brush(wx.Bitmap('texture.png'))
        else:
            self.bmpBrush = wx.BrushFromBitmap(wx.Bitmap('texture.png'))
Пример #2
0
    def OnPaint(self, event):
        width, height = self.GetClientSize()

        dc = wx.AutoBufferedPaintDC(self)
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()

        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.MakeSmaller()
        dc.SetFont(font)
        w, labelHeight = dc.GetTextExtent('Wy')

        dc.SetPen(wx.TRANSPARENT_PEN)
        name = self.brush_name

        if "STIPPLE" in name:
            bmp = images.Smiles.GetBitmap()
            bmp.SetMask(None)
            brush = wx.BrushFromBitmap(bmp)
        else:
            brush = wx.Brush(wx.BLUE, eval(name))

        dc.SetTextForeground(wx.BLACK)
        dc.DrawText(name, 1, 1)

        dc.SetBrush(brush)
        dc.DrawRectangle(5, labelHeight + 2, width - 10,
                         height - labelHeight - 5 - 2)
Пример #3
0
 def make_canvas(self, event=None):
     # create the paint canvas
     dc = wx.ClientDC(self.panel)
     # forms a wall-papered background
     # formed from repeating image tiles
     brush_bmp = wx.BrushFromBitmap(self.bmp)
     dc.SetBrush(brush_bmp)
     # draw a rectangle to fill the canvas area
     w, h = self.GetClientSize()
     dc.DrawRectangle(0, 0, w, h)
Пример #4
0
    def OnPaint(self, evt):
        if self.bitmap:
            obj = evt.GetEventObject()
            dc = wx.BufferedPaintDC(obj)

            dc.SetPen(wx.TRANSPARENT_PEN)
            dc.SetBrush(wx.BrushFromBitmap(self.bitmap))
            w, h = self.GetClientSize()
            dc.DrawRectangle(0, 0, w, h)
        else:
            evt.Skip()
 def OnPaint(self, evt):
     obj = evt.GetEventObject()
     dc = wx.BufferedPaintDC(obj)
     if self.bitmap:
         if self.tile:
             dc.SetPen(wx.TRANSPARENT_PEN)
             dc.SetBrush(wx.BrushFromBitmap(self.bitmap))
             w, h = self.GetClientSize()
             dc.DrawRectangle(0, 0, w, h)
         else:
             dc.SetBackground(wx.Brush(self.backgroundColour))
             dc.Clear()
             dc.DrawBitmap(self.bitmap, self.xpos, self.ypos, True)
     else:
         dc.SetBackground(wx.Brush(self.backgroundColour))
         dc.Clear()
Пример #6
0
    def OnPaint(self, event):
        dc = wx.PaintDC(self)

        brush = wx.BrushFromBitmap(
            wx.Bitmap('/home/soumyadc/Pictures/steel.png'))
        dc.SetBrush(brush)
        dc.DrawRectangle(0, 0, RW + 2 * RM, RH)
        dc.SetFont(self.font)

        dc.SetPen(wx.Pen('#F8FF25'))
        dc.SetTextForeground('#F8FF25')

        for i in range(RW):
            if not (i % 100):
                dc.DrawLine(i + RM, 0, i + RM, 10)
                w, h = dc.GetTextExtent(str(i))
                dc.DrawText(str(i), i + RM - w / 2, 11)
            elif not (i % 20):
                dc.DrawLine(i + RM, 0, i + RM, 8)
            elif not (i % 2):
                dc.DrawLine(i + RM, 0, i + RM, 4)
Пример #7
0
    def OnPaint(self, evt):
        if self.ready:
            dc = wx.BufferedPaintDC(self)
            dc.SetBackground(wx.Brush(self.backgroundColor))
            dc.Clear()

            if self.parentBitmap:
                dc.SetPen(wx.TRANSPARENT_PEN)
                dc.SetBrush(wx.BrushFromBitmap(self.parentBitmap))
                w, h = self.GetClientSize()
                dc.DrawRectangle(0, 0, w, h)
            elif self.parentColor:
                dc.SetPen(wx.TRANSPARENT_PEN)
                dc.SetBrush(wx.Brush(self.parentColor))
                w, h = self.GetClientSize()
                dc.DrawRectangle(0, 0, w, h)

            if not self.getEnabled():
                return

            bitmap = self.GetBitmap()
            if bitmap:
                dc.DrawBitmap(bitmap, 0, 0, True)
Пример #8
0
    def _on_paint(self, event):
        dc = wx.BufferedPaintDC(self)
        gcdc = wx.GCDC(dc)
        gc = gcdc.GetGraphicsContext()

        dc.Clear()


        # Get button size.
        w, h = self.GetSize()


        # Set font.
        if self.mouse_down and self.font_mouse_down is not None:
            gcdc.SetFont(self.font_mouse_down)
        elif self.mouse_in and self.font_hover is not None:
            gcdc.SetFont(self.font_hover)
        elif self.focus and self.font_focus is not None:
            gcdc.SetFont(self.font_focus)
        else:
            gcdc.SetFont(self.font_normal)


        # Get txt_w, txt_h, bmp_w, bmp_h and bmp position.

        txt_w, txt_h = gcdc.GetTextExtent(self.label)

        if self.mouse_down and self.bmp_mouse_down is not None:
            bmp = self.bmp_normal
            bmp_w, bmp_h = bmp[0].GetSize()
            position = bmp[1]
        elif self.focus and self.bmp_focus is not None:
            bmp = self.bmp_focus
            bmp_w, bmp_h = bmp[0].GetSize()
            position = bmp[1]
        elif self.mouse_in and self.bmp_hover is not None:
            bmp = self.bmp_hover
            bmp_w, bmp_h = bmp[0].GetSize()
            position = bmp[1]
        elif self.bmp_normal is not None:
            bmp = self.bmp_normal
            bmp_w, bmp_h = bmp[0].GetSize()
            position = bmp[1]
        else:
            bmp = False


        # Set background (brush).

        if self.bg_type == 'color':

            # Mouse down
            if self.mouse_down and self.bg_color_mouse_down is not None:
                gcdc.SetBrush(wx.Brush(self.bg_color_mouse_down))

            # Focus
            elif self.focus and self.bg_color_focus is not None:
                gcdc.SetBrush(wx.Brush(self.bg_color_focus))

            # Hover
            elif self.mouse_in and self.bg_color_hover is not None:
                gcdc.SetBrush(wx.Brush(self.bg_color_hover))

            # Normal
            else:
                gcdc.SetBrush(wx.Brush(self.bg_color_normal))

        elif self.bg_type == 'gradient':

            # Mouse down
            if self.mouse_down and self.bg_gradient_mouse_down is not None:
                gradbrush = gc.CreateLinearGradientBrush(
                    0, 0, 0, h,
                    self.bg_gradient_mouse_down[0],
                    self.bg_gradient_mouse_down[1])

            # Focus
            elif self.focus and self.bg_gradient_focus is not None:
                gradbrush = gc.CreateLinearGradientBrush(
                    0, 0, 0, h,
                    self.bg_gradient_focus[0], self.bg_gradient_focus[1])

            # Hover
            elif self.mouse_in and self.bg_gradient_hover is not None:
                gradbrush = gc.CreateLinearGradientBrush(
                    0, 0, 0, h,
                    self.bg_gradient_hover[0], self.bg_gradient_hover[1])

            # Normal
            else:
                gradbrush = gc.CreateLinearGradientBrush(
                    0, 0, 0, h,
                    self.bg_gradient_normal[0], self.bg_gradient_normal[1])

            gc.SetBrush(gradbrush)

        elif self.bg_type == 'image':

            # Mouse down
            if self.mouse_down and self.bg_image_mouse_down is not None:
                if 'phoenix' in wx.PlatformInfo:
                    brush = wx.Brush(self.bg_image_mouse_down)
                else:
                    brush = wx.BrushFromBitmap(self.bg_image_mouse_down)
                gcdc.SetBrush(brush)

            # Focus
            elif self.focus and self.bg_image_focus is not None:
                if 'phoenix' in wx.PlatformInfo:
                    brush = wx.Brush(self.bg_image_focus)
                else:
                    brush = wx.BrushFromBitmap(self.bg_image_focus)
                gcdc.SetBrush(brush)

            # Hover
            elif self.mouse_in and self.bg_image_hover is not None:
                if 'phoenix' in wx.PlatformInfo:
                    brush = wx.Brush(self.bg_image_hover)
                else:
                    brush = wx.BrushFromBitmap(self.bg_image_hover)
                gcdc.SetBrush(brush)

            # Normal
            else:
                if 'phoenix' in wx.PlatformInfo:
                    brush = wx.Brush(self.bg_image_normal)
                else:
                    brush = wx.BrushFromBitmap(self.bg_image_normal)
                gcdc.SetBrush(brush)

        else:
            gcdc.SetBrush(wx.Brush(self.parent.GetBackgroundColour()))


        # Set border variables.

        # Mouse down
        if self.mouse_down and self.border_mouse_down is not None:
            if self.border_mouse_down[0] == 0:
                border = ('#000000', 0)
            else:
                border = (self.border_mouse_down[1], self.border_mouse_down[0], wx.SOLID)
            radius = self.border_mouse_down[2]

        # Focus
        elif self.focus and self.border_focus is not None:
            if self.border_focus[0] == 0:
                border = ('#000000', 0)
            else:
                border = (self.border_focus[1], self.border_focus[0], wx.SOLID)
            radius = self.border_focus[2]

        # Hover
        elif self.mouse_in and self.border_hover is not None:
            if self.border_hover[0] == 0:
                border = ('#000000', 0)
            else:
                border = (self.border_hover[1], self.border_hover[0], wx.SOLID)
            radius = self.border_hover[2]

        # Normal
        elif self.border is not None:
            if self.border[0] == 0:
                border = ('#000000', 0)
            else:
                border = (self.border[1], self.border[0], wx.SOLID)
            radius = self.border[2]

        # No border
        else:
            border = ('#000000', 0)
            radius = 0


        # Set border (pen).

        if border[1] != 0:
            gcdc.SetPen(wx.Pen(border[0], border[1]))
        else:
            gcdc.SetPen(wx.TRANSPARENT_PEN)


        gcdc.DrawRoundedRectangle(0, 0, w, h, radius)


        # Draw text and bmp.

        if bmp:

            if position == 'left':
                if self.center:
                    bmp_x = (w - txt_w - bmp_w) / 2
                    bmp_y = (h - bmp_h) / 2

                    txt_x = (w - txt_w - bmp_w) / 2 + bmp_w
                    txt_y = (h - txt_h) / 2
                else:
                    bmp_x = border[1] + self.padding[3]
                    bmp_y = border[1] + self.padding[0]

                    txt_x = self.padding[3] + bmp_w
                    if bmp_h > txt_h:
                        txt_y = (bmp_h - txt_h) / 2 + border[1] + self.padding[0]
                    else:
                        txt_y = border[1] + self.padding[0]

            if position == 'right':
                if self.center:
                    bmp_x = (w - txt_w - bmp_w) / 2 + txt_w
                    bmp_y = (h - bmp_h) / 2

                    txt_x = (w - txt_w - bmp_w) / 2
                    txt_y = (h - txt_h) / 2
                else:
                    bmp_x = border[1] + self.padding[3] + txt_w
                    bmp_y = border[1] + self.padding[0]

                    txt_x = self.padding[3]
                    if bmp_h > txt_h:
                        txt_y = (bmp_h - txt_h) / 2 + border[1] + self.padding[0]
                    else:
                        txt_y = border[1] + self.padding[0]

            elif position == 'top':
                if self.center:
                    bmp_x = (w - bmp_w) / 2
                    bmp_y = (h - bmp_h - txt_h) / 2

                    txt_x = (w - txt_w) / 2
                    txt_y = (h - bmp_h - txt_h) / 2 + bmp_h
                else:
                    if bmp_w > txt_w:
                        bmp_x = border[1] + self.padding[3]
                        bmp_y = border[1] + self.padding[0]

                        txt_x = (bmp_w - txt_w) / 2 + border[1] + self.padding[3]
                        txt_y = border[1] + self.padding[0] + bmp_h
                    else:
                        bmp_x = (txt_w - bmp_w) / 2 + border[1] + self.padding[3]
                        bmp_y = border[1] + self.padding[0]

                        txt_x = border[1] + self.padding[3]
                        txt_y = border[1] + self.padding[0] + bmp_h

            elif position == 'bottom':
                if self.center:
                    bmp_x = (w - bmp_w) / 2
                    bmp_y = (h - txt_h - bmp_h) / 2 + txt_h

                    txt_x = (w - txt_w) / 2
                    txt_y = (h - txt_h - bmp_h) / 2
                else:
                    if bmp_w > txt_w:
                        bmp_x = border[1] + self.padding[3]
                        bmp_y = border[1] + self.padding[0] + txt_h

                        txt_x = (bmp_w - txt_w) / 2 + border[1] + self.padding[3]
                        txt_y = border[1] + self.padding[0]
                    else:
                        bmp_x = (txt_w - bmp_w) / 2 + border[1] + self.padding[3]
                        bmp_y = border[1] + self.padding[0] + txt_h

                        txt_x = border[1] + self.padding[3]
                        txt_y = border[1] + self.padding[0]

            gcdc.DrawBitmap(bmp[0], bmp_x, bmp_y)
        else:
            if self.center:
                txt_x = (w - txt_w) / 2
                txt_y = (h - txt_h) / 2
            else:
                txt_x = border[1] + self.padding[3]
                txt_y = border[1] + self.padding[0]

        # Text shadow
        if self.mouse_down and self.txt_shadow_mouse_down is not None:
            gcdc.SetTextForeground(self.txt_shadow_mouse_down[2])
            gcdc.DrawText(self.label,
                          txt_x + self.txt_shadow_mouse_down[0],
                          txt_y + self.txt_shadow_mouse_down[1])
        elif self.focus and self.txt_shadow_focus is not None:
            gcdc.SetTextForeground(self.txt_shadow_focus[2])
            gcdc.DrawText(self.label,
                          txt_x + self.txt_shadow_focus[0],
                          txt_y + self.txt_shadow_focus[1])
        elif self.mouse_in and self.txt_shadow_hover is not None:
            gcdc.SetTextForeground(self.txt_shadow_hover[2])
            gcdc.DrawText(self.label,
                          txt_x + self.txt_shadow_hover[0],
                          txt_y + self.txt_shadow_focus[1])
        elif self.txt_shadow_normal is not None:
            gcdc.SetTextForeground(self.txt_shadow_normal[2])
            gcdc.DrawText(self.label,
                          txt_x + self.txt_shadow_normal[0],
                          txt_y + self.txt_shadow_normal[1])

        # Text color
        if self.mouse_down and self.foreground_color_normal is not None:
            gcdc.SetTextForeground(self.foreground_color_normal)
        elif self.focus and self.foreground_color_focus is not None:
            gcdc.SetTextForeground(self.foreground_color_focus)
        elif self.mouse_in and self.foreground_color_hover is not None:
            gcdc.SetTextForeground(self.foreground_color_hover)
        elif self.foreground_color_normal is not None:
            gcdc.SetTextForeground(self.foreground_color_normal)

        # Draw text
        gcdc.DrawText(self.label, txt_x, txt_y)