Beispiel #1
0
    def DrawBox(self, dc):
        x0, y0 = self.X0, self.Y0
        w, h = self.W - self.X0 - self.X1, self.H - self.Y0 - self.Y1

        # Draw the background & surrounding box
        lineWidth = 1
        pen = wx.Pen(wx.BLACK, lineWidth, wx.SOLID)
        pen.SetJoin(wx.JOIN_MITER)
        with wx.DCPenChanger(dc,
                             pen), wx.DCBrushChanger(dc,
                                                     self._backgroundBrush):
            dc.DrawRectangle(x0 - lineWidth / 2, y0 - lineWidth / 2,
                             w + lineWidth, h + lineWidth)
 def draw(self, axes, dc):
     newPen = wx.Pen(wx.BLACK, self.lineWidth, wx.SOLID)
     newBrush = wx.Brush(mapColor(self.fillColor), wx.SOLID)
     with wx.DCPenChanger(dc, newPen), wx.DCBrushChanger(dc, newBrush):
         yMin = axes.yaxis.minVal
         X, Y, W, H = axes.getGeometry()
         #TODO: Is this round code the best way to go
         for x, y, w in zip(self.x, self.y, self.width):
             y = max(y, yMin)
             x1, x2 = W * axes.xaxis.scaleValue(np.array([x, x + w]))
             y1, y2 = H * axes.yaxis.scaleValue(np.array([yMin, y]))
             x1, x2, y2 = round(x1), round(x2), round(y2)
             #TODO: Verify the +1 here
             dc.DrawRectangle(X + x1, Y + (H - y2), x2 - x1 + 1, y2 + 1)
Beispiel #3
0
 def test_DCBrushChanger(self):
     dc = wx.ClientDC(self.frame)
     c = wx.DCBrushChanger(dc, wx.Brush('blue'))
     del c