Python wx.Pen() Examples
The following are 30
code examples of wx.Pen().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) # assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) DEBUG_MSG("__init__() 2: %s" % bitmap, 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #2
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def _Draw(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc=None): Size = self.Size dc.SetPen(self.Pen) xc,yc = WorldToPixel(self.XY) if self.Size <= 1: dc.DrawPoint(xc, yc) else: x = xc - Size/2.0 y = yc - Size/2.0 dc.SetBrush(self.Brush) dc.DrawRectangle(x, y, Size, Size) if HTdc and self.HitAble: HTdc.SetPen(self.HitPen) if self.Size <= 1: HTdc.DrawPoint(xc, xc) else: HTdc.SetBrush(self.HitBrush) HTdc.DrawRectangle(x, y, Size, Size)
Example #3
Source File: backend_wx.py From CogAlg with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) # assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) DEBUG_MSG("__init__() 2: %s" % bitmap, 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self.renderer = renderer
Example #4
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def SetUpDraw(self, dc, WorldToPixel, ScaleWorldToPixel, HTdc): """ Setup for draw :param `dc`: the dc to draw ??? :param `WorldToPixel`: ??? :param `ScaleWorldToPixel`: ??? :param `HTdc`: ??? """ dc.SetPen(self.Pen) dc.SetBrush(self.Brush) if HTdc and self.HitAble: HTdc.SetPen(self.HitPen) HTdc.SetBrush(self.HitBrush) return ( WorldToPixel(self.XY), ScaleWorldToPixel(self.WH) )
Example #5
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def _Draw(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc=None): CenterXY = WorldToPixel(self.XY) if self.Scaled: Diameter = ScaleWorldToPixel( (self.Diameter,self.Diameter) )[0] else: Diameter = self.Diameter WH = N.array((Diameter,Diameter), dtype = N.float) Corner = CenterXY - (WH / 2) dc.SetPen(self.Pen) for i, brush in enumerate(self.Brushes): dc.SetBrush( brush ) dc.DrawEllipticArc(Corner[0], Corner[1], WH[0], WH[1], self.Angles[i], self.Angles[i+1]) if HTdc and self.HitAble: if self.Scaled: radius = (ScaleWorldToPixel(self.Diameter)/2)[0]# just the x-coord else: radius = self.Diameter/2 HTdc.SetPen(self.HitPen) HTdc.SetBrush(self.HitBrush) HTdc.DrawCircle(CenterXY, radius)
Example #6
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def Draw( self, dc, foregroundColour, backgroundColour, coverage, aspectRatio=0, display=0, # deprecated ): dc.SetBackground(wx.Brush(backgroundColour)) dc.Clear() dc.SetPen(wx.Pen(foregroundColour, 1)) dc.SetBrush(wx.Brush(foregroundColour)) dc.SetPen(wx.Pen(foregroundColour, 1)) dc.SetBrush(wx.Brush(foregroundColour)) w, h = dc.GetSizeTuple() area = (w * h) * coverage / 100 width = height = sqrt(area) dc.DrawRectangle((w - width) / 2, (h - height) / 2, width, height)
Example #7
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def SetPen(self, LineColor, LineStyle, LineWidth): """ Set the Pen for this DrawObject :param `LineColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor` for valid entries :param `LineStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetLineStyle` for valid entries :param integer `LineWidth`: the width in pixels """ if (LineColor is None) or (LineStyle is None): self.Pen = wx.TRANSPARENT_PEN self.LineStyle = 'Transparent' else: self.Pen = self.PenList.setdefault( (LineColor, LineStyle, LineWidth), wx.Pen(LineColor, LineWidth, self.LineStyleList[LineStyle]))
Example #8
Source File: core.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def _DC_DrawPointList(self, points, pens=None): """ Draw a list of points as quickly as possible. :param points: A sequence of 2-element sequences representing each point to draw, (x,y). :param pens: If None, then the current pen is used. If a single pen then it will be used for all points. If a list of pens then there should be one for each point in points. """ if pens is None: pens = [] elif isinstance(pens, wx.Pen): pens = [pens] elif len(pens) != len(points): raise ValueError('points and pens must have same length') return self._DrawPointList(points, pens, [])
Example #9
Source File: backend_wx.py From coffeegrindsize with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) # assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) DEBUG_MSG("__init__() 2: %s" % bitmap, 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #10
Source File: wm_legend.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def draw_ticks(self, ticks): """ Print the tickmarks. Parameters ---------- ticks : list of (string, value, pixel) tuples """ pen = wx.Pen(wx.BLACK) self.mdc.SetPen(pen) text_w = max([self.mdc.GetTextExtent(_i[0])[0] for _i in ticks]) for tick in ticks: # Sorry, everything is measured from right to left... tick_end = self.grad_start_x - self.spacer tick_start = tick_end - self.tick_w self.mdc.DrawLine(tick_start, tick[2], tick_end, tick[2]) # Text origin is top left of bounding box. # Text is currently left-aligned. Maybe Change? text_x = tick_start - self.spacer - text_w text_y = tick[2] - self.text_h / 2 self.mdc.DrawText(tick[0], text_x, text_y)
Example #11
Source File: wm_legend.py From wafer_map with GNU General Public License v3.0 | 6 votes |
def draw_background(self): """ Draw the background box. If I don't do this, then the background is black. Could I change wx.EmptyBitmap() so that it defaults to white rather than black? """ # TODO: change the bitmap background to be transparent c = wx.Colour(200, 230, 230, 0) c = wx.Colour(255, 255, 255, 0) pen = wx.Pen(c) brush = wx.Brush(c) self.mdc.SetPen(pen) self.mdc.SetBrush(brush) self.mdc.DrawRectangle(0, 0, self.dc_w, self.dc_h)
Example #12
Source File: backend_wx.py From Computable with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) #assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #13
Source File: backend_wx.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) # assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) DEBUG_MSG("__init__() 2: %s" % bitmap, 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self.renderer = renderer
Example #14
Source File: backend_wx.py From matplotlib-4-abaqus with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) #assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #15
Source File: backend_wx.py From neural-network-animation with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) #assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #16
Source File: backend_wx.py From ImageFusion with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) #assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #17
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def __init__(self, bitmap, renderer): GraphicsContextBase.__init__(self) # assert self.Ok(), "wxMemoryDC not OK to use" DEBUG_MSG("__init__()", 1, self) DEBUG_MSG("__init__() 2: %s" % bitmap, 1, self) dc, gfx_ctx = self._cache.get(bitmap, (None, None)) if dc is None: dc = wx.MemoryDC() dc.SelectObject(bitmap) gfx_ctx = wx.GraphicsContext.Create(dc) gfx_ctx._lastcliprect = None self._cache[bitmap] = dc, gfx_ctx self.bitmap = bitmap self.dc = dc self.gfx_ctx = gfx_ctx self._pen = wx.Pen('BLACK', 1, wx.SOLID) gfx_ctx.SetPen(self._pen) self._style = wx.SOLID self.renderer = renderer
Example #18
Source File: chronolapsegui.py From chronolapse with MIT License | 6 votes |
def OnPaint(self, evt): # this doesnt appear to work at all... width,height = self.GetSizeTuple() # get drawing shit dc = wx.PaintDC(self) dc.SetPen(wx.Pen(wx.Colour(0,0,255,255))) dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220))) # build rect size = max(2, (width-10)*self.progress) rect = wx.Rect(5,8, size ,5) # draw rect dc.Clear() dc.BeginDrawing() dc.DrawRoundedRectangleRect(rect, 2) dc.EndDrawing() # end wxGlade
Example #19
Source File: chronolapse.py From chronolapse with MIT License | 6 votes |
def OnPaint(self, evt): # this doesnt appear to work at all... width,height = self.GetSizeTuple() # get drawing canvas dc = wx.PaintDC(self) dc.SetPen(wx.Pen(wx.Colour(0,0,255,255))) dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220))) # build rect size = max(2, (width-10)*self.progress) rect = wx.Rect(5,8, size ,5) # draw rect dc.Clear() dc.BeginDrawing() dc.DrawRoundedRectangleRect(rect, 2) dc.EndDrawing()
Example #20
Source File: ListCtrl.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def draw_sort_arrow(self, direction): b = wx.EmptyBitmap(self.icon_size, self.icon_size) w, h = b.GetSize() ho = (h - 5) / 2 dc = wx.MemoryDC() dc.SelectObject(b) colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_GRAYTEXT) dc.SetBackgroundMode(wx.TRANSPARENT) dc.Clear() dc.SetPen(wx.Pen(colour)) for i in xrange(5): if direction == 'down': j = 4 - i else: j = i dc.DrawLine(i,j+ho,9-i,j+ho) dc.SelectObject(wx.NullBitmap) b.SetMask(wx.Mask(b, (255, 255, 255))) return b
Example #21
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def Draw( self, dc, foregroundColour=(255,255,255), backgroundColour=(0,0,0), lineSize=1, orientation=0, display=0, # deprecated ): dc.SetBackground(wx.Brush(backgroundColour)) dc.Clear() dc.SetPen(wx.Pen(foregroundColour, lineSize)) dc.SetBrush(wx.Brush(foregroundColour)) w, h = dc.GetSizeTuple() if orientation == 0: for y in range(0, h, lineSize * 2): dc.DrawLine(0, y, w, y) elif orientation == 1: for x in range(0, w, lineSize * 2): dc.DrawLine(x, 0, x, h)
Example #22
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def Draw( self, dc, foregroundColour=(255, 255, 255), backgroundColour=(0, 0, 0), hCount=4, vCount=4, diameter=1, antialiasing=False ): diameter *= 1.0 dc.SetBackground(wx.Brush(backgroundColour)) dc.Clear() if antialiasing and diameter > 1: gc = wx.GraphicsContext.Create(dc) gc.Translate(0, 0) gc.Scale(1.0, 1.0) d = diameter + 1 else: gc = dc d = diameter + 2 gc.SetPen(wx.Pen(backgroundColour, 0)) gc.SetBrush(wx.Brush(foregroundColour)) w, h = dc.GetSizeTuple() if hCount == 1: xOffset = (w - diameter) / 2.0 - 1 width = 0 else: xOffset = -1 width = (w - diameter) / (hCount - 1) if vCount == 1: yOffset = (h - diameter) / 2.0 - 1 height = 0 else: yOffset = -1 height = (h - diameter) / (vCount - 1) for y in range(vCount): for x in range(hCount): gc.DrawEllipse(x * width + xOffset, y * height + yOffset, d, d)
Example #23
Source File: chronolapsegui.py From chronolapse with MIT License | 5 votes |
def setProgress(self, progress): self.progress = progress dc = wx.WindowDC(self) dc.SetPen(wx.Pen(wx.Colour(0,0,255,255))) dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220))) # build rect width,height = self.GetSizeTuple() size = max(2, (width-10)*self.progress) rect = wx.Rect(5,8, size ,5) # draw rect dc.Clear() dc.DrawRoundedRectangleRect(rect, 2)
Example #24
Source File: wxTableExtract.py From PyMuPDF-Utilities with GNU General Public License v3.0 | 5 votes |
def DrawRect(self, x, y, w, h): # Draw a rectangle (red border, transparent interior) dc = wx.ClientDC(self.PDFimage) # make a device control out of img dc.SetPen(wx.Pen("RED")) dc.SetBrush(wx.Brush("RED", style=wx.BRUSHSTYLE_TRANSPARENT)) self.redraw_bitmap() dc.DrawRectangle(x, y, w, h)
Example #25
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def Draw( self, dc, foregroundColour=(255, 255, 255), backgroundColour=(0, 0, 0), hCount=4, vCount=4, display=0, #deprecated ): dc.SetBackground(wx.Brush(backgroundColour)) dc.Clear() dc.SetPen(wx.Pen(foregroundColour, 1)) dc.SetBrush(wx.Brush(foregroundColour)) w, h = dc.GetSizeTuple() width = 1.0 * w / hCount height = 1.0 * h / vCount for x in range(0, hCount): for y in range(x % 2, vCount, 2): xpos1 = int(round(width * x)) xpos2 = int(round(width * (x + 1))) ypos1 = int(round(height * y)) ypos2 = int(round(height * (y + 1))) dc.DrawRectangle( xpos1, ypos1, xpos2 - xpos1, ypos2 - ypos1 )
Example #26
Source File: backend_wx.py From ImageFusion with MIT License | 5 votes |
def draw_rubberband(self, event, x0, y0, x1, y1): # Use an Overlay to draw a rubberband-like bounding box. dc = wx.ClientDC(self.canvas) odc = wx.DCOverlay(self.wxoverlay, dc) odc.Clear() # Mac's DC is already the same as a GCDC, and it causes # problems with the overlay if we try to use an actual # wx.GCDC so don't try it. if 'wxMac' not in wx.PlatformInfo: dc = wx.GCDC(dc) height = self.canvas.figure.bbox.height y1 = height - y1 y0 = height - y0 if y1<y0: y0, y1 = y1, y0 if x1<y0: x0, x1 = x1, x0 w = x1 - x0 h = y1 - y0 rect = wx.Rect(x0, y0, w, h) rubberBandColor = '#C0C0FF' # or load from config? # Set a pen for the border color = wx.NamedColour(rubberBandColor) dc.SetPen(wx.Pen(color, 1)) # use the same color, plus alpha for the brush r, g, b = color.Get() color.Set(r,g,b, 0x60) dc.SetBrush(wx.Brush(color)) dc.DrawRectangleRect(rect)
Example #27
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def draw_rubberband(self, x0, y0, x1, y1): dc = wx.ClientDC(self.canvas) # this would be required if the Canvas is a ScrolledWindow, # which is not the case for now # self.PrepareDC(dc) # delete old rubberband if self._rect: self.remove_rubberband(dc) # draw new rubberband dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID)) dc.SetBrush(wx.TRANSPARENT_BRUSH) self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0) dc.DrawRectangle(self._rect)
Example #28
Source File: PDFdisplay.py From PyMuPDF-Utilities with GNU General Public License v3.0 | 5 votes |
def draw_links(self, bmp, pno): dc = wx.MemoryDC() dc.SelectObject(bmp) dc.SetPen(wx.Pen("BLUE", width=1)) dc.SetBrush(wx.Brush("BLUE", style=wx.BRUSHSTYLE_TRANSPARENT)) pg_w = self.pg_ir.x1 - self.pg_ir.x0 pg_h = self.pg_ir.y1 - self.pg_ir.y0 zoom_w = float(bmp.Size[0]) / float(pg_w) zoom_h = float(bmp.Size[1]) / float(pg_h) for lnk in self.current_lnks: r = lnk["from"].irect wx_r = wx.Rect(int(r.x0 * zoom_w), int(r.y0 * zoom_h), int(r.width * zoom_w), int(r.height * zoom_h)) dc.DrawRectangle(wx_r[0], wx_r[1], wx_r[2]+1, wx_r[3]+1) if lnk["kind"] == fitz.LINK_GOTO: txt = "page " + str(lnk["page"] + 1) elif lnk["kind"] == fitz.LINK_GOTOR: txt = lnk["file"] elif lnk["kind"] == fitz.LINK_URI: txt = lnk["uri"] else: txt = "unkown destination" self.link_texts.append(txt) dc.SelectObject(wx.NullBitmap) dc = None return
Example #29
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def draw_rubberband(self, x0, y0, x1, y1): dc = wx.ClientDC(self.canvas) # this would be required if the Canvas is a ScrolledWindow, # which is not the case for now # self.PrepareDC(dc) # delete old rubberband if self._rect: self.remove_rubberband(dc) # draw new rubberband dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID)) dc.SetBrush(wx.TRANSPARENT_BRUSH) self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0) dc.DrawRectangle(self._rect)
Example #30
Source File: chronolapse.py From chronolapse with MIT License | 5 votes |
def setProgress(self, progress): self.progress = progress dc = wx.WindowDC(self) dc.SetPen(wx.Pen(wx.Colour(0,0,255,255))) dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220))) # build rect width,height = self.GetSizeTuple() size = max(2, (width-10)*self.progress) rect = wx.Rect(5,8, size ,5) # draw rect dc.Clear() dc.DrawRoundedRectangleRect(rect, 2)