Python wx 模块,Brush() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.Brush()

项目:cebl    作者:idfah    | 项目源码 | 文件源码
def refresh(self):
        dc = wx.MemoryDC(self.drawingBuffer)
        dc.SelectObject(self.drawingBuffer)

        dc.SetBackground(wx.Brush(self.background, style=wx.SOLID))
        dc.Clear()

        gc = wx.GraphicsContext.Create(dc)

        # do not draw if window is very small, right solution? XXX - idfah
        if self.winRadius < 1.0e-3:
            return

        self.draw(gc)

        dc.SelectObject(wx.NullBitmap)
        self.triggerRepaint()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def drawBars(self, gc):
        """Draw the bars reaching to the menu cells.
        """
        gc.SetPen(wx.Pen((80,80,80), 2))

        # figure bar width using number of bars and apothem of polygon
        r = 0.1 * self.winRadius
        barWidth = np.sqrt((r*(np.cos(self.angle)-1.0))**2+(r*np.sin(self.angle))**2)
        apothem = r * np.cos(self.angle/2.0)

        # for each angle, color, choice triple
        for angle, color, choice in zip(self.midAngles, self.curColors, self.choices):
            # set fill color
            gc.SetBrush(wx.Brush(color))

            # figure bar length
            barLength = self.bars[choice] * (0.70*self.winRadius - apothem)
                                            # smallRadius

            # rotate and draw bar
            gc.PushState()
            gc.Rotate(angle)
            gc.DrawRectangle(apothem, -barWidth/2.0, barLength, barWidth)
            gc.PopState()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, points, **attr):
        """
        Creates PolyMarker object
        :param `points`: sequence (array, tuple or list) of (x,y) points
        :keyword `attr`: keyword attributes, default to:
         ================================ ================================
         'colour'= 'black'                wx.Pen Colour any wx.Colour
         'width'= 1                       Pen width
         'size'= 2                        Marker size
         'fillcolour'= same as colour     wx.Brush Colour any wx.Colour
         'fillstyle'= wx.BRUSHSTYLE_SOLID wx.Brush fill style (use wx.BRUSHSTYLE_TRANSPARENT for no fill)
         'style'= wx.FONTFAMILY_SOLID     wx.Pen style
         'marker'= 'circle'               Marker shape
         'legend'= ''                     Line Legend to display
         ================================ ================================
         Marker Shapes:
         - 'circle'
         - 'dot'
         - 'square'
         - 'triangle'
         - 'triangle_down'
         - 'cross'
         - 'plus'
        """
        PolyPoints.__init__(self, points, attr)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def draw(self, dc, printerScale, coord=None):
        colour = self.attributes['colour']
        width = self.attributes['width'] * printerScale * self._pointSize[0]
        size = self.attributes['size'] * printerScale * self._pointSize[0]
        fillcolour = self.attributes['fillcolour']
        fillstyle = self.attributes['fillstyle']
        marker = self.attributes['marker']
        if colour and not isinstance(colour, wx.Colour):
            colour = wx.Colour(colour)
        if fillcolour and not isinstance(fillcolour, wx.Colour):
            fillcolour = wx.Colour(fillcolour)
        dc.SetPen(wx.Pen(colour, width))
        if fillcolour:
            dc.SetBrush(wx.Brush(fillcolour, fillstyle))
        else:
            dc.SetBrush(wx.Brush(colour, fillstyle))
        if coord == None:
            if len(self.scaled):  # bugfix for Mac OS X
                self._drawmarkers(dc, self.scaled, marker, size)
        else:
            self._drawmarkers(dc, coord, marker, size)  # draw legend marker
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Clear(self):
        """Erase the window."""
        self.last_PointLabel = None  # reset pointLabel
        dc = wx.BufferedDC(wx.ClientDC(self.canvas), self._Buffer)
        bbr = wx.Brush(self.GetBackgroundColour(), wx.SOLID)
        dc.SetBackground(bbr)
        dc.SetBackgroundMode(wx.SOLID)
        dc.Clear()
        if self._antiAliasingEnabled:
            try:
                dc = wx.GCDC(dc)
            except Exception:
                pass
        dc.SetTextForeground(self.GetForegroundColour())
        dc.SetTextBackground(self.GetBackgroundColour())
        self.last_draw = None
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def DrawPointLabel(self, dc, mDataDict):
        """This is the fuction that defines how the pointLabels are plotted
            dc - DC that will be passed
            mDataDict - Dictionary of data that you want to use for the pointLabel
            As an example I have decided I want a box at the curve point
            with some text information about the curve plotted below.
            Any wxDC method can be used.
        """
        # ----------
        dc.SetPen(wx.Pen(wx.BLACK))
        dc.SetBrush(wx.Brush(wx.BLACK, wx.BRUSHSTYLE_SOLID))
        sx, sy = mDataDict["scaledXY"]  # scaled x,y of closest point
        # 10by10 square centered on point
        dc.DrawRectangle(sx - 5, sy - 5, 10, 10)
        px, py = mDataDict["pointXY"]
        cNum = mDataDict["curveNum"]
        pntIn = mDataDict["pIndex"]
        legend = mDataDict["legend"]
        # make a string to display
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" % (
            cNum, legend, px, py, pntIn)
        dc.DrawText(s, sx, sy + 1)
        # -----------
项目:augment3D    作者:yulkang    | 项目源码 | 文件源码
def OnPaint(self, event):
        "Window 'paint' event."
        dc = wx.PaintDC(self.imView)
        dc = wx.BufferedDC(dc)

        # paint a background just so it isn't *so* boring.
        dc.SetBackground(wx.Brush("WHITE"))
        dc.Clear()
        dc.SetBrush(wx.Brush("GREY", wx.CROSSDIAG_HATCH))
        windowsize = self.imView.GetSizeTuple()
        dc.DrawRectangle(0, 0, windowsize[0], windowsize[1])
        bmpX0 = 0
        bmpY0 = 0
        if self.bitmap is not None:
            if self.loadCentered:
                bmpX0 = (windowsize[0] - self.bitmap.Width) / 2
                bmpY0 = (windowsize[1] - self.bitmap.Height) / 2
            dc.DrawBitmap(self.bitmap, bmpX0, bmpY0, False)

    # ------------------------------------------------------------
    #  ImFrame.ConvertWXToPIL()
    #  Expropriated from Andrea Gavana's
    #  ShapedButton.py in the wxPython dist
    # ------------------------------------------------------------
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
def drawScore(self,dc):            
        dc.SetFont(self.smFont)
        scoreLabelSize = dc.GetTextExtent(u"SCORE")
        bestLabelSize = dc.GetTextExtent(u"BEST")
        curScoreBoardMinW = 15*2+scoreLabelSize[0]
        bstScoreBoardMinW = 15*2+bestLabelSize[0]
        curScoreSize = dc.GetTextExtent(str(self.curScore))
        bstScoreSize = dc.GetTextExtent(str(self.bstScore))
        curScoreBoardNedW = 10+curScoreSize[0]
        bstScoreBoardNedW = 10+bstScoreSize[0]
        curScoreBoardW = max(curScoreBoardMinW,curScoreBoardNedW)
        bstScoreBoardW = max(bstScoreBoardMinW,bstScoreBoardNedW)
        dc.SetBrush(wx.Brush((187,173,160)))
        dc.SetPen(wx.Pen((187,173,160)))
        dc.DrawRoundedRectangle(505-15-bstScoreBoardW,40,bstScoreBoardW,50,3)
        dc.DrawRoundedRectangle(505-15-bstScoreBoardW-5-curScoreBoardW,40,curScoreBoardW,50,3)
        dc.SetTextForeground((238,228,218))
        dc.DrawText(u"BEST",505-15-bstScoreBoardW+(bstScoreBoardW-bestLabelSize[0])/2,48)
        dc.DrawText(u"SCORE",505-15-bstScoreBoardW-5-curScoreBoardW+(curScoreBoardW-scoreLabelSize[0])/2,48)
        dc.SetTextForeground((255,255,255))
        dc.DrawText(str(self.bstScore),505-15-bstScoreBoardW+(bstScoreBoardW-bstScoreSize[0])/2,68)
        dc.DrawText(str(self.curScore),505-15-bstScoreBoardW-5-curScoreBoardW+(curScoreBoardW-curScoreSize[0])/2,68)
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
def drawTiles(self,dc):
        dc.SetFont(self.scFont)
        for row in range(4):
            for col in range(4):
                value = self.data[row][col]
                color = self.colors[value]
                if value==2 or value==4:
                    dc.SetTextForeground((119,110,101))
                else:
                    dc.SetTextForeground((255,255,255))
                dc.SetBrush(wx.Brush(color))
                dc.SetPen(wx.Pen(color))
                dc.DrawRoundedRectangle(30+col*115,165+row*115,100,100,2)
                size = dc.GetTextExtent(str(value))
                while size[0]>100-15*2:
                    self.scFont = wx.Font(self.scFont.GetPointSize()*4/5,wx.SWISS,wx.NORMAL,wx.BOLD,face=u"Roboto")
                    dc.SetFont(self.scFont)
                    size = dc.GetTextExtent(str(value))
                if value!=0: dc.DrawText(str(value),30+col*115+(100-size[0])/2,165+row*115+(100-size[1])/2)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        points = [wx.Point(int(round((self.Pos.x - 2) * scalex)) - 3,
                           int(round((self.Pos.y - 2) * scaley)) - 2),
                  wx.Point(int(round((self.Pos.x + self.Size[0] + 2) * scalex)) + 4,
                           int(round((self.Pos.y - 2) * scaley)) - 2),
                  wx.Point(int(round((self.Pos.x + self.Size[0] / 2) * scalex)),
                           int(round((self.Pos.y + self.Size[1] + 3) * scaley)) + 4)]
        dc.DrawPolygon(points)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Draws divergence
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightedText(dc, text, highlights, x, y):
    current_pen = dc.GetPen()
    dc.SetPen(wx.TRANSPARENT_PEN)
    for start, end, highlight_type in highlights:
        dc.SetBrush(wx.Brush(highlight_type[0]))
        offset_width, offset_height = dc.GetTextExtent(text[:start[1]])
        part = text[start[1]:end[1] + 1]
        part_width, part_height = dc.GetTextExtent(part)
        dc.DrawRectangle(x + offset_width, y, part_width, part_height)
        dc.SetTextForeground(highlight_type[1])
        dc.DrawText(part, x + offset_width, y)
    dc.SetPen(current_pen)
    dc.SetTextForeground(wx.BLACK)


# -------------------------------------------------------------------------------
#                           Graphic element base class
# -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        pen = MiterPen(HIGHLIGHTCOLOR, 2 * scalex + 5)
        pen.SetCap(wx.CAP_BUTT)
        dc.SetPen(pen)
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        parent_pos = self.ParentBlock.GetPosition()
        posx = parent_pos[0] + self.Pos.x
        posy = parent_pos[1] + self.Pos.y
        xstart = parent_pos[0] + self.Pos.x
        ystart = parent_pos[1] + self.Pos.y
        if self.Direction[0] < 0:
            xstart += 1
        if self.Direction[1] < 0:
            ystart += 1
        xend = xstart + CONNECTOR_SIZE * self.Direction[0]
        yend = ystart + CONNECTOR_SIZE * self.Direction[1]
        dc.DrawLine(round((xstart + self.Direction[0]) * scalex), round((ystart + self.Direction[1]) * scaley),
                    round(xend * scalex), round(yend * scaley))
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Adds an highlight to the connector
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        # Draw two rectangles for representing the contact
        left_left = (self.Pos.x - 1) * scalex - 2
        right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
        top = (self.Pos.y - 1) * scaley - 2
        width = 4 * scalex + 5
        height = (self.Size[1] + 3) * scaley + 5

        dc.DrawRectangle(left_left, top, width, height)
        dc.DrawRectangle(right_left, top, width, height)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Adds an highlight to the connection
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,255,0), width=1, style=wx.SOLID))
        dc.SetTextForeground((255,255,0))
        font = wx.Font(8, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)

        dc.SetFont(font)
        data = self.data[0 if len(self.data)==0 else key['cur']]

        pos = [f(*(i[0][1], i[0][0])) for i in data]
        for i in pos:dc.DrawCircle(i[0], i[1], 2)

        txts = ['id={}'.format(i) for i in range(len(data))]
        dc.DrawTextList(txts, pos)

        if data[0][1]==None:return
        lt = [f(*(i[1][1], i[1][0])) for i in data]
        rb = [f(*(i[1][3], i[1][2])) for i in data]
        rects = [(x1,y1,x2-x1,y2-y1) for (x1,y1),(x2,y2) in zip(*(lt,rb))]
        dc.DrawRectangleList(rects, brushes = wx.Brush((0,0,0), wx.BRUSHSTYLE_TRANSPARENT))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetTextForeground((255,255,0))
        font = wx.Font(8, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(font)

        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        dc.SetBrush(wx.Brush((0,255,0)))
        pos = [f(*(i[1], i[0])) for i in self.xy[self.msk]]
        for i in pos:dc.DrawCircle(int(i[0]), int(i[1]), 2)


        dc.SetPen(wx.Pen((255,0,0), width=1, style=wx.SOLID))
        dc.SetBrush(wx.Brush((255,0,0)))
        pos = [f(*(i[1], i[0])) for i in self.xy[~self.msk]]
        for i in pos:dc.DrawCircle(int(i[0]), int(i[1]), 2)
项目:bids    作者:robertoostenveld    | 项目源码 | 文件源码
def OnPaint(self, event):
        "Window 'paint' event."
        dc = wx.PaintDC(self.imView)
        dc = wx.BufferedDC(dc)

        # paint a background just so it isn't *so* boring.
        dc.SetBackground(wx.Brush("WHITE"))
        dc.Clear()
        dc.SetBrush(wx.Brush("GREY", wx.CROSSDIAG_HATCH))
        windowsize = self.imView.GetSizeTuple()
        dc.DrawRectangle(0, 0, windowsize[0], windowsize[1])
        bmpX0 = 0
        bmpY0 = 0
        if self.bitmap is not None:
            if self.loadCentered:
                bmpX0 = (windowsize[0] - self.bitmap.Width) / 2
                bmpY0 = (windowsize[1] - self.bitmap.Height) / 2
            dc.DrawBitmap(self.bitmap, bmpX0, bmpY0, False)

    # ------------------------------------------------------------
    #  ImFrame.ConvertWXToPIL()
    #  Expropriated from Andrea Gavana's
    #  ShapedButton.py in the wxPython dist
    # ------------------------------------------------------------
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        if self.Primary:
            for e in self.eyes:
                if e.obj == 1:
                    dc.SetPen(wx.Pen(wx.Colour(112,173,71)))
                elif e.obj == 2:
                    dc.SetPen(wx.Pen(wx.Colour(237,125,49)))
                else:
                    dc.SetPen(wx.Pen(self.P_color))
                dc.DrawLine(self.pos_x, self.pos_y, 
                        self.pos_x + e.SightDistance*math.sin(self.dir_Angle + e.OffSetAngle),
                        self.pos_y - e.SightDistance*math.cos(self.dir_Angle + e.OffSetAngle))

        super(Agent, self).Draw(dc)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def OnDrawItem(self, dc, rect, item, flags):
        if item == wx.NOT_FOUND:
            # painting the control, but there is no valid item selected yet
            return 
        font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Segoe UI')             
        dc.SetFont(font)
        if flags == 3:
            margin = 3    
        else:
            margin = 1
        r = wx.Rect(*rect)  # make a copy
        r.Deflate(margin, margin)
        tam = self.OnMeasureItem(item)-2
        dc.SetPen(wx.Pen("grey", style=wx.TRANSPARENT))
        color_name = self.GetString(item)     
        color = self.colors.get(color_name)
        if not color:
            color = wx.NamedColour(color_name)
        dc.SetBrush(wx.Brush(color))
        dc.DrawRectangle(r.x, r.y, tam, tam)
        dc.DrawText(self.GetString(item), r.x + tam + 2, r.y)
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        dc.DrawCircle(self.pos_x, self.pos_y, self.rad)
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def OnTimer(self, event):
        if self.World is not None:
            # Graphics Update
            self.bdc = wx.BufferedDC(self.cdc, self.bmp)
            self.gcdc = wx.GCDC(self.bdc)
            self.gcdc.Clear()

            self.gcdc.SetPen(wx.Pen('white'))
            self.gcdc.SetBrush(wx.Brush('white'))
            self.gcdc.DrawRectangle(0,0,640,640)

            for ag in [self.World.A]:
                ag.Draw(self.gcdc)
            self.World.BBox.Draw(self.gcdc)
            self.World.Course.Draw(self.gcdc)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def canvasCallback(self, event=None):
        # create the device context
        dc = wx.ClientDC(self)
        brushBMP = wx.Brush(self.bmp)
        dc.SetBrush(brushBMP)
        width, height = self.GetClientSize()
        dc.DrawRectangle(0, 0, width, height)

#=================================================================================
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def canvasCallback(self, event=None):
        # create the device context
        dc = wx.ClientDC(self)
        brushBMP = wx.Brush(self.bmp)
        dc.SetBrush(brushBMP)
        width, height = self.GetClientSize()
        dc.DrawRectangle(0, 0, width, height)

#=================================================================================
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def onPaint(self, e):
        w,h = self.GetSize()

        dc = wx.AutoBufferedPaintDC(self)

        # Surface
        dc.SetBrush(wx.Brush(COLOR_BACK))
        dc.DrawRectangle(0, 0, w+1, h+1)

        # Le quadrillage
        dc.SetPen(wx.Pen(COLOR_GRID, 2))
#        for i in range(0, 600, 25):
#            dc.DrawLine(0, i, w, i)
#            dc.DrawLine(i, 0, i, h)

        dc.SetBrush(wx.Brush(COLOR_GRID,style=wx.TRANSPARENT))
        for i in range(8):
            dc.DrawCircle(w/2,h/2,GRID_CIRCLE_RADIUS*(7*i))
#            dc.DrawCircle(300,300,CIRCLE_RADIUS*(7*i))

        for i in range(self.numSpeakers):
            vars.getVars("Speakers")[i].draw(dc, COLOR_AV)
            vars.getVars("Speakers")[i].drawZone(dc, COLOR_AV)


        # ecriture de valeurs
        if self.catch:            
            # conversion des positions X et Y entre 0 et 1
            x = self.pos[0] / float(w)
            y = 1.- self.pos[1] / float(h)

            # affiche la position normalisee du pointeur
            dc.DrawText("%.3f, %.3f" % (x,y), 10, 10)

        # Les cercles
        self.blueCircle.draw(dc,COLOR_BLUE)
        self.redCircle.draw(dc,COLOR_RED)
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def draw(self,dc,color):
        dc.SetPen(wx.Pen(color, 1))
        dc.SetBrush(wx.Brush(color))
        dc.DrawCircle(self.x, self.y, self.c)

        # à l'appel, cette fonction ajuste la position du rectangle 
        # pour l'utilisation de la fonction ContainsXY
        self.rect.x = self.x - self.c
        self.rect.y = self.y - self.c
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def draw(self,dc,color):
        numero = self.getNumOut()
        dc.SetPen(wx.Pen(COLOR_BACK, 1))
        dc.SetBrush(wx.Brush(color))
        dc.DrawCircle(self.x, self.y, self.c)
        dc.DrawText("%d" % numero, self.x-(self.c/3),self.y-(self.c/1.75))

        self.rect.x = self.x - self.c
        self.rect.y = self.y - self.c
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def drawZone(self,dc,color):
        radius = self.getZoneRad()
        dc.SetPen(wx.Pen(color,1))
        dc.SetBrush(wx.Brush(wx.Colour(100,100,100,75)))
        dc.DrawCircle(self.x,self.y,radius)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def refresh(self):
        """Refresh the drawing area after a change has been made.
        This method sets up a drawing context, calls self.draw
        to update the drawing and then calls self.triggerRepaint
        in order to update the drawing area on the screen.

        This method should be called each time a change is
        made that requires the drawing area to be updated.
        """
        dc = wx.MemoryDC(self.drawingBuffer)
        dc.SelectObject(self.drawingBuffer)

        dc.SetBackground(wx.Brush(self.background, style=wx.SOLID))
        dc.Clear()

        # do not draw if window is very small, right solution? XXX - idfah
        if self.winRadius < 1.0e-3:
            return

        #dc.BeginDrawing()
        self.draw(dc)
        #dc.EndDrawing()

        #del dc
        dc.SelectObject(wx.NullBitmap)
        self.triggerRepaint()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def __init__(self):
        self.coords = np.array([0.0,0.0])
        self.velocity = np.array([0.0,0.0])

        self.pen = wx.Pen((250,250,250), 2)
        self.brush = wx.Brush((255,255,255))
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def Render(self, rect, dc, state):
        if state != 0:
            self.log.write('Render: %s, %d' % (rect, state))

        if not state & dataview.DATAVIEW_CELL_SELECTED:
            # we'll draw a shaded background to see if the rect correctly
            # fills the cell
            dc.SetBrush(wx.Brush('light grey'))
            dc.SetPen(wx.TRANSPARENT_PEN)
            rect.Deflate(1, 1)
            dc.DrawRoundedRectangleRect(rect, 2)

        # And then finish up with this helper function that draws the
        # text for us, dealing with alignment, font and color
        # attributes, etc
        self.RenderText(self.value,
                        4,  # x-offset, to compensate for the rounded rectangles
                        rect,
                        dc,
                        state  # wxDataViewCellRenderState flags
                        )

    # The HasEditorCtrl, CreateEditorCtrl and GetValueFromEditorCtrl
    # methods need to be implemented if this renderer is going to
    # support in-place editing of the cell value, otherwise they can
    # be omitted.
项目:squaremap3    作者:kawaiicthulhu    | 项目源码 | 文件源码
def Draw(self, dc):
        ''' Draw the tree map on the device context. '''
        self.hot_map = []
        #dc.BeginDrawing()
        brush = wx.Brush( self.BackgroundColour  )
        dc.SetBackground( brush )
        dc.Clear()
        if self.model:
            self.max_depth_seen = 0
            font = self.FontForLabels(dc)
            dc.SetFont(font)
            self._em_size_ = dc.GetFullTextExtent( 'm', font )[0]
            w, h = dc.GetSize()
            self.DrawBox( dc, self.model, 0,0,w,h, hot_map = self.hot_map )
        #dc.EndDrawing()
项目:squaremap3    作者:kawaiicthulhu    | 项目源码 | 文件源码
def BrushForNode( self, node, depth=0 ):
        """Create brush to use to display the given node"""
        if node == self.selectedNode:
            colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
        elif node == self.highlightedNode:
            colour = wx.Colour( red=0, green=255, blue=0 )
        else:
            colour = self.adapter.background_color(node, depth)
            if not colour:
                red = (depth * 10)%255
                green = 255-((depth * 5)%255)
                blue = (depth * 25)%255
                colour = wx.Colour( red, green, blue )
        return wx.Brush( colour  )
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def _drawRubberBand(self, corner1, corner2):
        """Draws/erases rect box from corner1 to corner2"""
        ptx, pty, rectWidth, rectHeight = self._point2ClientCoord(
            corner1, corner2)
        # draw rectangle
        dc = wx.ClientDC(self.canvas)
        dc.SetPen(wx.Pen(wx.BLACK))
        dc.SetBrush(wx.Brush(wx.WHITE, wx.BRUSHSTYLE_TRANSPARENT))
        dc.SetLogicalFunction(wx.INVERT)
        dc.DrawRectangle(ptx, pty, rectWidth, rectHeight)
        dc.SetLogicalFunction(wx.COPY)
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
def clearScreenShot(self, bmp):
        dc = wx.MemoryDC()
        dc.SelectObject(bmp)
        dc.SetBackground(wx.Brush("white"))
        dc.Clear()
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
def drawBg(self,dc):
        dc.SetBackground(wx.Brush((250,248,239)))   #????
        dc.Clear()
        dc.SetBrush(wx.Brush((187,173,160)))        #????
        dc.SetPen(wx.Pen((187,173,160)))            #??pen
        dc.DrawRoundedRectangle(15,150,475,475,5)   #??
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.SetBrush(wx.Brush(wx.NamedColour("LIGHT GREY")))

        dc.DrawRectangle(self.Position.x, self.Position.y,
                         self.Size.width, self.Size.height)

        w, h = dc.GetTextExtent(self.Label)
        dc.DrawText(self.Label,
                    self.Position.x + (self.Size.width - w) / 2,
                    self.Position.y + (self.Size.height - h) / 2)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnPaint(self, event):
        """
        Callback for Paint Event
        @param event: Paint event
        """
        # Get buffered paint DC for tool tip
        dc = wx.AutoBufferedPaintDC(self)
        dc.Clear()

        # Set DC drawing style
        dc.SetPen(wx.BLACK_PEN)
        dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
        dc.SetFont(self.Font)

        # Draw Tool tip
        dc.BeginDrawing()
        tip_width, tip_height = self.GetToolTipSize()

        # Draw background rectangle
        dc.DrawRectangle(0, 0, tip_width, tip_height)

        # Draw tool tip text
        line_offset = 0
        for line in self.Tip:
            dc.DrawText(line, 2, line_offset + 2)
            line_width, line_height = dc.GetTextExtent(line)
            line_offset += line_height

        dc.EndDrawing()

        event.Skip()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def RefreshScaling(self, refresh=True):
        properties = self.Controler.GetProjectProperties(self.Debug)
        scaling = properties["scaling"][self.CurrentLanguage]
        if scaling[0] != 0 and scaling[1] != 0:
            self.Scaling = scaling
            if self.DrawGrid:
                width = max(2, int(scaling[0] * self.ViewScale[0]))
                height = max(2, int(scaling[1] * self.ViewScale[1]))
                bitmap = wx.EmptyBitmap(width, height)
                dc = wx.MemoryDC(bitmap)
                dc.SetBackground(wx.Brush(self.Editor.GetBackgroundColour()))
                dc.Clear()
                dc.SetPen(MiterPen(wx.Colour(180, 180, 180)))
                dc.DrawPoint(0, 0)
                self.GridBrush = wx.BrushFromBitmap(bitmap)
            else:
                self.GridBrush = wx.TRANSPARENT_BRUSH
        else:
            self.Scaling = None
            self.GridBrush = wx.TRANSPARENT_BRUSH
        page_size = properties["pageSize"]
        if page_size != (0, 0):
            self.PageSize = map(int, page_size)
            self.PagePen = MiterPen(wx.Colour(180, 180, 180))
        else:
            self.PageSize = None
            self.PagePen = wx.TRANSPARENT_PEN
        if refresh:
            self.RefreshVisibleElements()
            self.Editor.Refresh(False)

    # -------------------------------------------------------------------------------
    #                          Refresh functions
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        dc.DrawRectangle(int(round((self.Pos.x - 1) * scalex)) - 2,
                         int(round((self.Pos.y - 1) * scaley)) - 2,
                         int(round((self.Size.width + 3) * scalex)) + 5,
                         int(round((self.Size.height + 3) * scaley)) + 5)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Draws the handles of this element if it is selected
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        # If user trying to connect wire with wrong input, highlight will become red.
        if self.ErrHighlight and not (self.EndConnected):
            highlightcolor = wx.RED
        else:
            highlightcolor = HIGHLIGHTCOLOR
        dc.SetPen(MiterPen(highlightcolor, (2 * scalex + 5)))
        dc.SetBrush(wx.Brush(highlightcolor))
        dc.SetLogicalFunction(wx.AND)
        # Draw the start and end points if they are not connected or the mouse is over them
        if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):
            dc.DrawCircle(round(self.Points[0].x * scalex),
                          round(self.Points[0].y * scaley),
                          (POINT_RADIUS + 1) * scalex + 2)
        if len(self.Points) > 1 and (not self.EndConnected or self.OverEnd):
            dc.DrawCircle(self.Points[-1].x * scalex, self.Points[-1].y * scaley, (POINT_RADIUS + 1) * scalex + 2)
        # Draw the wire lines and the last point (it seems that DrawLines stop before the last point)
        if len(self.Points) > 1:
            points = [wx.Point(round((self.Points[0].x - self.Segments[0][0]) * scalex),
                               round((self.Points[0].y - self.Segments[0][1]) * scaley))]
            points.extend([wx.Point(round(point.x * scalex), round(point.y * scaley)) for point in self.Points[1:-1]])
            points.append(wx.Point(round((self.Points[-1].x + self.Segments[-1][0]) * scalex),
                                   round((self.Points[-1].y + self.Segments[-1][1]) * scaley)))
        else:
            points = []
        dc.DrawLines(points)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

        if self.StartConnected is not None:
            self.StartConnected.DrawHighlightment(dc)
            self.StartConnected.Draw(dc)
        if self.EndConnected is not None:
            self.EndConnected.DrawHighlightment(dc)
            self.EndConnected.Draw(dc)

    # Draws the wire lines and points
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        #dc.SetPen(wx.TRANSPARENT_PEN)
        dc.SetBrush(wx.Brush((0,0,255)))
        if self.style:
            for i in self.pts:dc.DrawCircle(f(*i.pt), 3)
        tidx = self.pair[:,1-self.host][self.msk]
        dc.SetBrush(wx.Brush((255,255,0)))
        for i in tidx:
            dc.DrawCircle(f(*self.pts[i].pt), 3)
        if self.cur!=-1:
            dc.SetBrush(wx.Brush((255,0,0)))
            dc.DrawCircle(f(*self.pts[self.cur].pt), 3)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def Draw(self, dc):
        ''' Draw the tree map on the device context. '''
        self.hot_map = []
        dc.BeginDrawing()
        brush = wx.Brush( self.BackgroundColor  )
        dc.SetBackground( brush )
        dc.Clear()
        if self.model:
            self.max_depth_seen = 0
            dc.SetFont(self.FontForLabels(dc))
            w, h = dc.GetSize()
            self.DrawBox( dc, self.model, 0,0,w,h, hot_map = self.hot_map )
        dc.EndDrawing()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def BrushForNode( self, node, depth=0 ):
        """Create brush to use to display the given node"""
        if node == self.selectedNode:
            color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
        elif node == self.highlightedNode:
            color = wx.Color( red=0, green=255, blue=0 )
        else:
            color = self.adapter.background_color(node, depth)
            if not color:
                red = (depth * 10)%255
                green = 255-((depth * 5)%255)
                blue = (depth * 25)%255
                color = wx.Color( red, green, blue )
        return wx.Brush( color  )
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        dc.DrawCircle(self.pos_x, self.pos_y, self.rad)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        for e in self.eyes:
            if e.obj == 1:
                dc.SetPen(wx.Pen(wx.Colour(112,173,71)))
            elif e.obj == 2:
                dc.SetPen(wx.Pen(wx.Colour(237,125,49)))
            else:
                dc.SetPen(wx.Pen(self.P_color))
            dc.DrawLine(self.pos_x, self.pos_y, 
                    self.pos_x + e.SightDistance*math.sin(self.dir_Angle + e.OffSetAngle),
                    self.pos_y - e.SightDistance*math.cos(self.dir_Angle + e.OffSetAngle))

        super(Agent, self).Draw(dc)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        dc.DrawCircle(self.pos_x, self.pos_y, self.rad)
项目:DeepQNetworkTest    作者:Chachay    | 项目源码 | 文件源码
def Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.SetBrush(wx.Brush(self.B_color))
        dc.DrawCircle(self.pos_x, self.pos_y, self.rad)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def _get_sash_DC(self):
        dc = wx.ClientDC(self)  
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.SetBrush(wx.Brush(self.sashColor))   
        return dc
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def create_background(self):
        w,h = self.GetSize()
        self.background_bitmap = wx.EmptyBitmap(w, h)
        dc = wx.MemoryDC(self.background_bitmap)
        gc = wx.GraphicsContext_Create(dc)
        dc.SetBrush(wx.Brush("#FFFFFF"))
        dc.Clear()
        dc.DrawRectangle(0,0,w,h)

        off = h // self.chnls // 2
        gc.SetPen(wx.Pen('#000000', width=1, style=wx.SOLID))
        gc.SetBrush(wx.Brush("#FFFFFF", style=wx.TRANSPARENT))
        dc.SetTextForeground("#444444")
        if sys.platform in "darwin":
            font, ptsize = dc.GetFont(), dc.GetFont().GetPointSize()
            font.SetPointSize(ptsize - 3)
            dc.SetFont(font)
        else:
            font = dc.GetFont()
            font.SetPointSize(8)
            dc.SetFont(font)
        tickstep = w // 10
        if tickstep < 40:
            timelabel = "%.1f"
        elif tickstep < 80:
            timelabel = "%.2f"
        elif tickstep < 120:
            timelabel = "%.3f"
        else:
            timelabel = "%.4f"
        timestep = (self.end - self.begin) * 0.1
        for i, samples in enumerate(self.img):
            y = h // self.chnls * i
            if len(samples):
                gc.DrawLines(samples)
            dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
            dc.DrawLine(0, y+off, w, y+off)
#            for j in range(10):
#                dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
#                dc.DrawLine(j*tickstep, 0, j*tickstep, h)
#                dc.DrawText(timelabel % (self.begin+j*timestep), j*tickstep+2, h-y-12)
            dc.SetPen(wx.Pen('#000000', width=1))
            dc.DrawLine(0, h-y, w, h-y)

        dc.SelectObject(wx.NullBitmap)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def drawCells(self, gc):
        """Draw the menu cells.
        """
        gc.PushState()

        # setup the pen for drawing the
        # outline of the cells
        gc.SetPen(wx.Pen((80,80,80), 2))

        # for each cell
        for i,choice in enumerate(self.choices):
        #in xrange(len(self.angles)-1):
            gc.PushState()

            # set color for filling cell
            gc.SetBrush(wx.Brush(self.curColors[i]))

            # cell border is a contigous path
            path = gc.CreatePath()

            # inner and outer radii of cells
            smallRadius = 0.70 * self.winRadius
            bigRadius = 0.90 * self.winRadius

            if choice in self.highlightPop:
                smallRadius = 0.65 * self.winRadius
                bigRadius = 0.95 * self.winRadius

            if choice in self.highlightJump:
                gc.Scale(1.1, 1.1)

            # draw arcs defining cell border
            path.AddArc(0, 0, bigRadius, self.angles[i], self.angles[i+1], True)
            path.AddArc(0, 0, smallRadius, self.angles[i+1], self.angles[i], False)

            # close the path and draw it
            path.CloseSubpath()
            gc.DrawPath(path)

            gc.PopState()

        gc.PopState()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def drawCellText(self, gc):
        """Draw the text in each cell.
        """
        # centers for text in each cell
        radius = 0.8 * self.winRadius
        textCenters = radius * np.array((np.cos(self.midAngles), np.sin(self.midAngles))).T

        #gc.SetFont(self.font, wx.Colour('black')) # wxpython3
        gc.SetFont(self.font)

        # for each cell
        for i,choice in enumerate(self.choices):
            gc.PushState()

            # translate and rotate to text center
            gc.Translate(textCenters[i,0], textCenters[i,1])
            gc.Rotate(self.rotation)

            # find width and height of text
            textW, textH = gc.GetTextExtent(choice)
            textWPlus = textW + 0.2 * textW
            textHPlus = textH + 0.1 * textH

            # set pen color for text
            gc.SetPen(wx.Pen((80,80,80), 2))

            # set fill color for text backdrop
            #gc.SetBrush(wx.Brush((240,240,240)))
            gc.SetBrush(wx.Brush((255,255,255,200)))

            # draw a box behind the text to increase visibility
            scale = 0.01 * self.winRadius
            gc.DrawRoundedRectangle(-scale*textWPlus/2.0,
                                    -scale*textHPlus/2.0,
                                     scale*textWPlus,
                                     scale*textHPlus, 1)

            # scale and draw text
            gc.Scale(scale, scale)
            gc.DrawText(choice, -textW/2.0, -textH/2.0)

            gc.PopState()