Esempio n. 1
0
    def Draw(self, dc):
        width, height = self.GetClientSize()
        if not width or not height:
            return

        gcdc = wx.GCDC(dc)

        gcdc.SetPen(wx.NullPen)

        bg = self.GetParent().GetBackgroundColour()
        gcdc.SetBackground(wx.Brush(bg, wx.SOLID))
        gcdc.Clear()

        border_radius = self.GetBorderRadius()
        border = self.GetBorderWidth()

        if border:
            gcdc.SetBrush(wx.Brush(self.GetBorderColor()))
            gcdc.DrawRoundedRectangle(0, 0, width, height, border_radius)

        w, h = width - 2 * border, height - 2 * border
        border_radius -= border

        gcdc.SetBrush(wx.Brush(self.GetBackgroundColour()))
        gcdc.DrawRoundedRectangle(border, border, w, h, border_radius)

        dc.SetFont(self.GetFont())
        label = self.GetLabel()
        w, h = dc.GetTextExtent(label)
        x, y = (width - w) / 2, (height - h) / 2
        dc.DrawText(label, x, y)
Esempio n. 2
0
    def Draw(self, dc):
        width, height = self.GetClientSize()
        if not width or not height:
            return

        gcdc = wx.GCDC(dc)

        bg = self.GetParent().GetBackgroundColour()
        gcdc.SetBackground(wx.Brush(bg, wx.SOLID))
        gcdc.Clear()

        x, y = width / 2, height / 2
        radius = min(x, y)
        border = int(radius / 20)
        gcdc.SetPen(wx.Pen(self.GetBorderColor(), border))
        gcdc.SetBrush(wx.Brush(bg, wx.SOLID))
        gcdc.DrawCircle(x, y, radius - border)

        # Set font size 70% of the diameter
        v = str(self.value)
        s = max(dc.GetTextExtent(v))
        scale = 2 * radius * .7 / s
        font = self.GetFont()
        font.SetPointSize(round(font.GetPointSize() * scale))
        dc.SetFont(font)

        w, h = dc.GetTextExtent(v)
        x, y = (width - w) / 2, (height - h) / 2
        dc.DrawText(v, x, y)
Esempio n. 3
0
        def Draw(self, dc):
            width, height = self.GetClientSize()
            if not width or not height:
                return

            gcdc = wx.GCDC(dc)

            gcdc.SetPen(wx.NullPen)

            bg = self.GetParent().GetBackgroundColour()
            gcdc.SetBackground(wx.Brush(bg, wx.SOLID))
            gcdc.Clear()

            color = self.success_color if self.success else self.failure_color
            gcdc.SetBrush(wx.Brush(color))

            x = width / 2
            y = height / 2
            gcdc.DrawCircle(x, y, min(x, y))