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

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

项目:cebl    作者:idfah    | 项目源码 | 文件源码
def drawCenterPolygon(self, gc):
        """Draw the polygon at the center of the pie menu.
        """
        gc.PushState()

        # set border and fill colors
        gc.SetPen(wx.Pen((80,80,80), 2))
        gc.SetBrush(wx.Brush((0,0,0)))

        # radius of circle that circumscribes the polygon
        radius = 0.1 * self.winRadius
        points = radius * np.array((np.cos(self.angles), np.sin(self.angles))).T

        # draw the polygon
        gc.DrawLines(points)

        gc.PopState()
项目: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 draw(self, dc, printerScale, coord=None):
        colour = self.attributes['colour']
        width = self.attributes['width'] * printerScale * self._pointSize[0]
        style = self.attributes['style']
        if not isinstance(colour, wx.Colour):
            if IsNotWX4():
                colour = wx.NamedColour(colour)
            else:
                colour = wx.Colour(colour)
        pen = wx.Pen(colour, width, style)
        pen.SetCap(wx.CAP_BUTT)
        dc.SetPen(pen)
        if coord is None:
            if len(self.scaled):  # bugfix for Mac OS X
                dc.DrawLines(self.scaled)
        else:
            dc.DrawLines(coord)  # draw legend line
项目: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 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)
        # -----------
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
def DrawFromSelectedNode(self, msg):
        t = msg.replace("][", ",").replace("[", "").replace("]", "").split(",")
        osx = int(t[0])
        osy = int(t[1])
        oex = int(t[2])
        oey = int(t[3])
        i = wx.Bitmap(os.path.join(self.screenShotDir, "screenshot.png"))
        dc = wx.MemoryDC(i)
        dc.SetPen(wx.Pen(wx.RED, 1))
        #???(wxpython????drawline?drawlines, ??drawrect??????)
        dc.DrawLine(osx, osy, osx, oey)
        dc.DrawLine(osx, osy, oex, osy)
        dc.DrawLine(oex, osy, oex, oey)
        dc.DrawLine(osx, oey, oex, oey)
        dc.SelectObject(wx.NullBitmap)
        self.screenShot.SetBitmap(i) 
        self.Refresh(eraseBackground=True, rect=None)
项目: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)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self):
        l, t, r, b = 35,35,15,35
        w = self.width - l - r
        h = self.height - t - b
        if self.data is None:return
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.Clear()

        left, low, right, high = self.extent
        self.draw_coord(dc, w, h, l, t, r, b)
        for xs, ys, c, lw in self.data:
            ys = h+t - (ys - low)*(h/(high-low))
            xs = l+(xs-left)*(1.0/(right-left)*w)
            pts = list(zip(xs, ys))
            dc.SetPen(wx.Pen(c, width=lw, style=wx.SOLID))
            dc.DrawLines(pts)
项目: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)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID))
        dc.SetTextForeground(Setting['tcolor'])
        font = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(font)
        dc.DrawLines([f(*i) for i in self.buf])
        for i in self.buf:dc.DrawCircle(f(*i),2)
        for line in self.body:
            dc.DrawLines([f(*i) for i in line])
            for i in line:dc.DrawCircle(f(*i),2)
            pts = np.array(line)
            mid = (pts[:-1]+pts[1:])/2

            dis = norm((pts[:-1]-pts[1:]), axis=1)
            unit = 1 if self.unit is None else self.unit[0]
            for i,j in zip(dis, mid):
                dc.DrawText('%.2f'%(i*unit), f(*j))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID))
        dc.SetTextForeground(Setting['tcolor'])
        linefont = wx.Font(8, wx.FONTFAMILY_DEFAULT, 
                           wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)

        dc.SetFont(linefont)
        dc.DrawLines([f(*i) for i in self.buf])
        for i in self.buf:dc.DrawCircle(f(*i),2)
        for line in self.body:
            dc.DrawLines([f(*i) for i in line])
            for i in line:dc.DrawCircle(f(*i),2)
            pts = np.array(line)
            v1 = pts[:-2]-pts[1:-1]
            v2 = pts[2:]-pts[1:-1]
            a = np.sum(v1*v2, axis=1)*1.0
            a/=norm(v1,axis=1)*norm(v2,axis=1)
            ang = np.arccos(a)/np.pi*180
            for i,j in zip(ang,line[1:-1]):
                dc.DrawText('%.0f'%i, f(*j))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID))
        dc.SetTextForeground(Setting['tcolor'])
        font = wx.Font(10, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)

        dc.SetFont(font)
        dc.DrawLines([f(*i) for i in self.buf])
        for i in self.buf:dc.DrawCircle(f(*i),2)

        for pg in self.body:
            plg = Polygon(pg)
            dc.DrawLines([f(*i) for i in pg])
            for i in pg: dc.DrawCircle(f(*i),2)
            area, xy = plg.area, plg.centroid
            if self.unit!=None: 
                area *= self.unit[0]**2
            dc.DrawText('%.1f'%area, f(xy.x, xy.y))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen(Setting['color'], width=1, style=wx.SOLID))
        dc.SetTextForeground(Setting['tcolor'])
        linefont = wx.Font(10, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(linefont)
        if len(self.buf)>1:
            dc.DrawLines([f(*i) for i in self.buf])
        for i in self.buf:dc.DrawCircle(f(*i),2)
        for line in self.body:
            dc.DrawLines([f(*i) for i in line])
            for i in line:dc.DrawCircle(f(*i),2)
            pts = np.array(line)
            mid = (pts[:-1]+pts[1:])/2

            dxy = (pts[:-1]-pts[1:])
            dis = norm(dxy, axis=1)
            unit = 1 if self.unit is None else self.unit[0]
            for i,j in zip(dis, mid):
                dc.DrawText('%.2f'%(i*unit), f(*j))
项目: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))
        for i in range(0, len(self.xList)-1):
            dc.DrawLine(self.xList[i], self.yList[i], self.xList[i+1],self.yList[i+1])
项目: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 Draw(self, dc):
        dc.SetPen(wx.Pen(self.P_color))
        dc.DrawLine(self.pos_x, self.pos_y, 
                self.pos_x + self.EYE.OverHang*math.cos(self.dir_Angle + self.EYE.OffSetAngle),
                self.pos_y - self.EYE.OverHang*math.sin(self.dir_Angle + self.EYE.OffSetAngle))
        super(Agent, self).Draw(dc)
项目: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)
项目: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 __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))
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def DrawROI(self):
        object = self.object
        bmp = self.image.GetBitmap()
        w =  bmp.GetWidth()
        h =  bmp.GetHeight()
        roi = [0]*6
        for i in range(3):
            roi[2*i] = int(self.roi[2*i].value.GetValue()) - 1
            roi[2*i+1] = int(self.roi[2*i+1].value.GetValue())
        axis = int(self.scrollaxis.value.GetValue())
        if axis == 1:
            x1 = int(float(w*roi[4])/float(object.shape[2]) +0.5)
            x2 = int(float(w*(roi[5]))/float(object.shape[2]) -0.5)
            y1 = int(float(h*roi[2])/float(object.shape[1]) +0.5)
            y2 = int(float(h*(roi[3]))/float(object.shape[1]) -0.5)
        elif axis == 2:
            x1 = int(float(w*roi[4])/float(object.shape[2]) +0.5)
            x2 = int(float(w*(roi[5]))/float(object.shape[2]) -0.5)
            y1 = int(float(h*roi[0])/float(object.shape[0]) +0.5)
            y2 = int(float(h*(roi[1]))/float(object.shape[0]) -0.5)
        elif axis == 3:
            x1 = int(float(w*roi[2])/float(object.shape[1]) +0.5)
            x2 = int(float(w*(roi[3]))/float(object.shape[1]) -0.5)
            y1 = int(float(h*roi[0])/float(object.shape[0]) +0.5)
            y2 = int(float(h*(roi[1]))/float(object.shape[0]) -0.5)
        self.dc = wx.MemoryDC(bmp)
        self.dc.SelectObject(bmp)
        self.dc.SetPen(wx.Pen(wx.RED, 1))
        self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
        self.dc.DrawLine(x1, 1, x1, h)
        self.dc.DrawLine(x2, 1, x2, h)
        self.dc.DrawLine(1, y1, w, y1)
        self.dc.DrawLine(1, y2, w, y2)
        self.dc.SelectObject(wx.NullBitmap)
        self.image.SetBitmap(bmp)
        self.Layout()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def DrawROI(self):
        object = self.object
        bmp = self.image.GetBitmap()
        w =  bmp.GetWidth()
        h =  bmp.GetHeight()
        roi = [0]*6
        for i in range(3):
            roi[2*i] = int(self.roi[2*i].value.GetValue()) - 1
            roi[2*i+1] = int(self.roi[2*i+1].value.GetValue()) - 1
        axis = int(self.scrollaxis.value.GetValue())
        if axis == 1:
            rx = int(float(w*roi[4])/float(object.shape[2]) +0.5)
            rw = int(float(w*(roi[5] - roi[4] +1.0))/float(object.shape[2]) +0.5)
            ry = int(float(h*roi[2])/float(object.shape[1]) +0.5)
            rh = int(float(h*(roi[3] - roi[2] +1.0))/float(object.shape[1]) +0.5)
        elif axis == 2:
            rx = int(float(w*roi[4])/float(object.shape[2]) +0.5)
            rw = int(float(w*(roi[5] - roi[4] +1.0))/float(object.shape[2]) +0.5)
            ry = int(float(h*roi[0])/float(object.shape[0]) +0.5)
            rh = int(float(h*(roi[1] - roi[0] +1.0))/float(object.shape[0]) +0.5)
        elif axis == 3:
            rx = int(float(w*roi[2])/float(object.shape[1]) +0.5)
            rw = int(float(w*(roi[3] - roi[2] +1.0))/float(object.shape[1]) +0.5)
            ry = int(float(h*roi[0])/float(object.shape[0]) +0.5)
            rh = int(float(h*(roi[1] - roi[0] +1.0))/float(object.shape[0]) +0.5)
        self.dc = wx.MemoryDC(bmp)
        self.dc.SelectObject(bmp)
        self.dc.SetPen(wx.Pen(wx.RED, 1))
        self.dc.SetBrush(wx.TRANSPARENT_BRUSH)
        self.dc.DrawRectangle(rx, ry, rw, rh)
        self.dc.SelectObject(wx.NullBitmap)
        self.image.SetBitmap(bmp)
        self.Layout()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.ancestor = parent
        self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
        self.colour = wx.Colour(30,70,115, alpha=wx.ALPHA_OPAQUE)
        self.canvas = PlotCanvas(self)
        if IsNotWX4():
            self.canvas.SetInitialSize(size=self.GetClientSize())
            self.canvas.SetShowScrollbars(True)
            self.canvas.SetEnableZoom(False)
            self.canvas.SetFontSizeAxis(point=12)
            self.canvas.SetFontSizeTitle(point=12)
            self.canvas.SetGridColour(wx.Colour(0, 0, 0))
            self.canvas.SetForegroundColour(wx.Colour(0, 0, 0))
            self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255))
        else:
            self.canvas.axesPen = wx.Pen(self.colour, width=1, style=wx.PENSTYLE_SOLID)
            self.canvas.SetForegroundColour(wx.Colour(0, 0, 0))
            self.canvas.SetBackgroundColour(wx.Colour(255, 255, 255))
            self.canvas.enableGrid = (True,True)
            self.canvas.fontSizeAxis = self.fontpointsize
            self.canvas.fontSizeTitle = self.fontpointsize
        self.vbox = wx.BoxSizer(wx.VERTICAL)
        self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW)
        self.paused = False
        self.hbox_btn = wx.BoxSizer(wx.HORIZONTAL)
        self.hbox_btn.AddSpacer(20)
        self.button_pause =wx.Button(self, label="Pause Graph")
        self.Bind(wx.EVT_BUTTON, self.OnClickPauseButton, self.button_pause)
        self.hbox_btn.Add(self.button_pause)
        self.button_save =wx.Button(self, label="Save Data")
        self.Bind(wx.EVT_BUTTON, self.OnClickSaveButton, self.button_save)
        self.hbox_btn.Add(self.button_save)
        self.vbox.Add(self.hbox_btn, 0, wx.EXPAND)
        self.SetSizer(self.vbox)
        self.Fit()
        self.Show()
        self.data_poll_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.UpdateGraph, self.data_poll_timer)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, points, **attr):
        """
        Creates PolyLine object
        :param `points`: sequence (array, tuple or list) of (x,y) points making up line
        :keyword `attr`: keyword attributes, default to:
         ==========================  ================================
         'colour'= 'black'           wx.Pen Colour any wx.Colour
         'width'= 1                  Pen width
         'style'= wx.PENSTYLE_SOLID  wx.Pen style
         'legend'= ''                Line Legend to display
         ==========================  ================================
        """
        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]
        style = self.attributes['style']
        if not isinstance(colour, wx.Colour):
            colour = wx.Colour(colour)
        pen = wx.Pen(colour, width, style)
        pen.SetCap(wx.CAP_ROUND)
        dc.SetPen(pen)
        if coord == None:
            if len(self.scaled):  # bugfix for Mac OS X
                dc.DrawSpline(self.scaled)
        else:
            dc.DrawLines(coord)  # draw legend line
项目: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)
项目:opencv-plgs    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,0,0), width=2, style=wx.SOLID))
        for line in self.foreline: dc.DrawLines([f(*i) for i in line])
        dc.SetPen(wx.Pen((0,0,255), width=2, style=wx.SOLID))
        for line in self.backline: dc.DrawLines([f(*i) for i in line])
项目: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 DrawBoundingBoxes(self, bboxes, dc=None):
        """
        Draw a list of bounding box on Viewer in the order given using XOR
        logical function
        @param bboxes: List of bounding boxes to draw on viewer
        @param dc: Device Context of Viewer (default None)
        """
        # Get viewer Device Context if not given
        if dc is None:
            dc = self.Viewer.GetLogicalDC()

        # Save current viewer scale factors before resetting them in order to
        # avoid rubberband pen to be scaled
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)

        # Set DC drawing style
        dc.SetPen(wx.Pen(wx.WHITE, style=wx.DOT))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.SetLogicalFunction(wx.XOR)

        # Draw the bounding boxes using viewer scale factor
        for bbox in bboxes:
            if bbox is not None:
                dc.DrawRectangle(
                    bbox.x * scalex, bbox.y * scaley,
                    bbox.width * scalex, bbox.height * scaley)

        dc.SetLogicalFunction(wx.COPY)

        # Restore Viewer scale factor
        dc.SetUserScale(scalex, scaley)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def MiterPen(colour, width=1, style=wx.SOLID):
    pen = wx.Pen(colour, width, style)
    pen.SetJoin(wx.JOIN_MITER)
    pen.SetCap(wx.CAP_PROJECTING)
    return pen


# -------------------------------------------------------------------------------
#                    Helpers for highlighting text
# -------------------------------------------------------------------------------
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        if len(self.body)>1:
            dc.DrawLines([f(*i) for i in self.body])
        for i in [self.lt, (self.lt+self.rt)/2, self.rt]:
            for j in [self.tp, (self.tp+self.bm)/2, self.bm]:
                dc.DrawCircle(f(i,j),2)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        for line in self.body:
            if len(line)>1:
                dc.DrawLines([f(*i) for i in line])
                for i in line:dc.DrawCircle(f(*i),2)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        if(len(self.body)>1):
            dc.DrawLines([f(*i) for i in self.body])
        for i in self.body:dc.DrawCircle(f(*i),2)
        dc.DrawCircle(f(self.lt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f(self.rt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.tp),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.bm),2)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        for i in self.body:
            dc.DrawCircle(f(*i), 2)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f):
        dc.SetPen(wx.Pen(RoiManager.get_color(), width=RoiManager.get_lw(), style=wx.SOLID))
        for pg in self.body:
            dc.DrawLines([f(*i) for i in pg[0]])
            if self.issimple():
                for i in pg[0]: dc.DrawCircle(f(*i),2)
            for hole in pg[1]:
                dc.DrawLines([f(*i) for i in hole])
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw_ruler(self, dc):
        dc.SetPen(wx.Pen((255,255,255), width=2, style=wx.SOLID))
        x1 = max(self.imgbox[0], self.box[0])+5
        x2 = min(self.imgbox[2], self.box[2])+x1-10
        pixs = (x2-x1+10)*self.ips.size[1]/10.0/self.imgbox[2]
        h = min(self.imgbox[1]+self.imgbox[3],self.box[3])-5
        dc.DrawLineList([(x1,h,x2,h)])
        dc.DrawLineList([(i,h,i,h-8) for i in np.linspace(x1, x2, 3)])
        dc.DrawLineList([(i,h,i,h-5) for i in np.linspace(x1, x2, 11)])

        dc.SetTextForeground((255,255,255))
        k, unit = self.ips.unit
        text = 'Unit = %.1f %s'%(k*pixs, unit)
        dw,dh = dc.GetTextExtent(text)
        dc.DrawText(text, (x2-dw, h-10-dh))
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw_coord(self, dc, w, h, l, t, r, b):
        xs = [5, 10, 20, 40, 50, 100, 200, 400, 500, 1000, 2000, 4000, 10000]
        n, dx, dy = len(self.data), 0, 0
        left, low, right, high = self.extent
        for i in xs[::-1]: 
            if (right-left)*1.0/i<=10:dx=i
        for i in xs[::-1]: 
            if (high-low)*1.0/i<=10:dy=i
        dc.SetPen(wx.Pen((0, 0, 0), width=1, style=wx.SOLID))
        dc.DrawRectangle(l, t, w+1, h+1)
        dc.SetPen(wx.Pen((100, 100, 100), width=1, style=wx.SOLID))
        for i in range(int(ceil(left*1.0/dx)*dx), int(right)+1, dx):
            x = l+(i-left)*1.0/(right-left)*w
            dc.DrawLine(x, t, x, t+h)
            dc.DrawText(str(i), x-5, t+h)
        for i in range(int(ceil(low*1.0/dy)*dy), int(high)+1, dy):
            y = h+t-(i-low)*1.0/(high-low)*h
            dc.DrawLine(l, y, l+w, y)
            dc.DrawText(str(i), 5, y-5)

        titlefont = wx.Font(18, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(titlefont)
        dw,dh = dc.GetTextExtent(self.title)
        dc.DrawText(self.title, l+w/2-dw/2, 3)

        lablelfont = wx.Font(14, wx.FONTFAMILY_DEFAULT, 
                       wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
        dc.SetFont(lablelfont)
        dw,dh = dc.GetTextExtent(self.labelx)
        dc.DrawText(self.labelx, l+w-dw, t+h+15)
        dc.DrawText(self.labely, 5, 10)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,255,0), width=3, 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)

        ids = self.graph.nodes()
        pts = [self.graph.node[i]['o'] for i in ids]
        pts = [f(i[1], i[0]) for i in pts]
        dc.DrawPointList(pts)
        dc.DrawTextList([str(i) for i in ids], pts)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f):
        print(self.x, self.y)
        dc.SetPen(wx.Pen((255,255,0), width=1, style=wx.SOLID))
        dc.DrawLines([f(0,self.y),f(self.w,self.y)])
        dc.DrawLines([f(self.x,0),f(self.x,self.h)])
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        sox, soy = f(self.para['ox'], self.para['oy'])
        dc.DrawCircle((sox, soy), 5)
        a = np.linspace(0, 2*np.pi, 20)
        dc.DrawLines(list(zip(sox+np.cos(a)*40, soy+np.sin(a)*40)))
        a = self.para['ang']*np.pi/180
        dc.DrawCircle((sox+np.cos(a)*40, soy+np.sin(a)*40), 3)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        body = [(self.lt,self.bm),(self.rt,self.bm),
                (self.rt,self.tp),(self.lt,self.tp),(self.lt,self.bm)]
        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        dc.DrawLines([f(*i) for i in body])
        for i in body:dc.DrawCircle(f(*i),2)
        dc.DrawCircle(f(self.lt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f(self.rt, (self.tp+self.bm)/2),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.tp),2)
        dc.DrawCircle(f((self.lt+self.rt)/2, self.bm),2)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((255,0,0), width=2, style=wx.SOLID))
        dc.DrawLines([f(*i) for i in self.line])
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((0,255,0), width=1, style=wx.SOLID))
        if len(self.buf[0])>1:
            dc.DrawLines([f(*i) for i in self.buf[0]])
        for i in self.buf[0]: dc.DrawCircle(f(*i),2)
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self, dc, f, **key):
        dc.SetPen(wx.Pen((0,255,255), width=1, style=wx.SOLID))
        if len(self.buf)>1:
            dc.DrawLines([f(*i) for i in self.buf])
        for i in self.buf:dc.DrawCircle(f(*i),2)