Python wx.TRANSPARENT_PEN Examples
The following are 14
code examples of wx.TRANSPARENT_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: mining.py From nuxhash with GNU General Public License v3.0 | 7 votes |
def Render(self, cell, dc, state): position = cell.GetPosition() for device in self._Devices: box = self.GetTextExtent(device['name']) RADIUS = DeviceListRenderer.CORNER_RADIUS if device['vendor'] == 'nvidia': color = self._ColorDb.Find('LIME GREEN') else: color = self._ColorDb.Find('LIGHT GREY') dc.SetBrush(wx.Brush(color)) dc.SetPen(wx.TRANSPARENT_PEN) shadeRect = wx.Rect( position, wx.Size(box.GetWidth() + RADIUS*2, box.GetHeight() + RADIUS*2)) dc.DrawRoundedRectangle(shadeRect, RADIUS) textRect = wx.Rect( wx.Point(position.x + RADIUS, position.y + RADIUS), box) self.RenderText(device['name'], 0, textRect, dc, state) position = wx.Point( position.x, (position.y + box.GetHeight() + RADIUS*2 + RADIUS)) return True
Example #2
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 #3
Source File: GraphicCommons.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
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 # -------------------------------------------------------------------------------
Example #4
Source File: PouInstanceVariablesPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def PaintItem(self, item, dc, level, align): CT.CustomTreeCtrl.PaintItem(self, item, dc, level, align) rightimages = item.GetRightImages() if len(rightimages) > 0: images_bbx = self.GetItemRightImagesBBox(item) r_image_w, _r_image_h = self._imageListRight.GetSize(rightimages[0]) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangle(images_bbx.x, images_bbx.y, images_bbx.width, images_bbx.height) x_pos = images_bbx.x + 4 for r_image in rightimages: self._imageListRight.Draw( r_image, dc, x_pos, images_bbx.y + 4, wx.IMAGELIST_DRAW_TRANSPARENT) x_pos += r_image_w + 4
Example #5
Source File: ListCtrlPrinter.py From bookhub with MIT License | 6 votes |
def DrawDecoration(self, dc, bounds, block): """ Draw this decoration """ rect = self._CalculateRect(bounds) if self.color: if self.toColor is None: dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(self.color)) dc.DrawRectangle(*rect) else: dc.GradientFillLinear(wx.Rect(*rect), self.color, self.toColor) if self.pen: dc.SetPen(self.pen) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.DrawRectangle(*rect)
Example #6
Source File: FCObjects.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def SetHitPen(self, HitColor, LineWidth): """ Set the pen used for hit test, do not call directly. :param `HitColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor` :param integer `LineWidth`: the line width in pixels """ if not self.HitLine: self.HitPen = wx.TRANSPARENT_PEN else: self.HitPen = self.PenList.setdefault( (HitColor, "solid", self.HitLineWidth), wx.Pen(HitColor, self.HitLineWidth, self.LineStyleList["Solid"]) ) ## Just to make sure that they will always be there ## the appropriate ones should be overridden in the subclasses
Example #7
Source File: CustomWidgets.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def draw_bar(self, dc, rect): if self.percent == None: return 0 dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(self.remaining_color)) dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height) dc.SetBrush(wx.Brush(self.completed_color)) dc.DrawRectangle(rect.x, rect.y, rect.width * self.percent, rect.height) return 0
Example #8
Source File: ListCtrl.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def OnEraseBackground(self, event=None): nsp = self.GetScrollPos(wx.VERTICAL) if self._last_scrollpos != nsp: self._last_scrollpos = nsp # should only refresh visible items, hmm wx.CallAfter(self.Refresh) dc = wx.ClientDC(self) # erase the section of the background which is not covered by the # items or the selected column highlighting dc.SetBackground(wx.Brush(self.GetBackgroundColour())) f = self.GetRect() r = wx.Region(0, 0, f.width, f.height) x = self.GetVisibleViewRect() offset = self._get_origin_offset(include_header=True) x.Offset(offset) r.SubtractRect(x) if '__WXMSW__' in wx.PlatformInfo: c = self.GetColumnRect(self.enabled_columns.index(self.selected_column)) r.SubtractRect(c) dc.SetClippingRegionAsRegion(r) dc.Clear() if '__WXMSW__' in wx.PlatformInfo: # draw the selected column highlighting under the items dc.DestroyClippingRegion() r = wx.Region(0, 0, f.width, f.height) r.SubtractRect(x) dc.SetClippingRegionAsRegion(r) dc.SetPen(wx.TRANSPARENT_PEN) hc = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) r = highlight_color(hc.Red()) g = highlight_color(hc.Green()) b = highlight_color(hc.Blue()) hc.Set(r, g, b) dc.SetBrush(wx.Brush(hc)) dc.DrawRectangle(c.x, c.y, c.width, c.height)
Example #9
Source File: LaserRender.py From meerk40t with MIT License | 5 votes |
def set_pen(self, gc, stroke, width=1.0): c = stroke if c is not None and c != 'none': swizzle_color = swizzlecolor(c) self.color.SetRGB(swizzle_color) self.pen.SetColour(self.color) self.pen.SetWidth(width) gc.SetPen(self.pen) else: gc.SetPen(wx.TRANSPARENT_PEN)
Example #10
Source File: Viewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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 # -------------------------------------------------------------------------------
Example #11
Source File: LogViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
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)
Example #12
Source File: OLVPrinter.py From bookhub with MIT License | 5 votes |
def DrawDecoration(self, dc, bounds, block): """ Draw this decoration """ if self.color is None: return dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(self.color)) dc.DrawRectangle(*bounds) #----------------------------------------------------------------------------
Example #13
Source File: CustomWidgets.py From BitTorrent with GNU General Public License v3.0 | 4 votes |
def draw_bar(self, dc, rect): # size events can catch this if self.percent is None: return y1 = rect.y w = rect.width h = rect.height if self.resolution <= 0: return # sort, so we get 0...N, h, t keys = self.grouped.keys() keys.sort() for k in keys: v = self.grouped[k] if k == 'h': c = self.completed_color elif k == 't': c = self.transfering_color else: c = self.gradient(k) dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(c)) def draw(b, e): b = float(b) e = float(e) r = float(self.resolution) x1 = (b / r) * w x2 = (e / r) * w # stupid floats x1 = int(rect.x + x1) x2 = int(rect.x + x2) dc.DrawRectangle(x1, y1, x2 - x1, h) if isinstance(v, SparseSet): for (b, e) in v.iterrange(): draw(b, e) elif isinstance(v, dict): for b in v.iterkeys(): draw(b, b + 1) elif isinstance(v, set): #for b in v: # draw(b, b + 1) # maybe this is better? (fewer rectangles) l = list(v) l.sort() for (b, e) in collapse(l): draw(b, e) else: # assumes sorted! for (b, e) in collapse(v): draw(b, e)
Example #14
Source File: Viewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def DoDrawing(self, dc, printing=False): if printing: if getattr(dc, "printing", False): font = wx.Font(self.GetFont().GetPointSize(), wx.MODERN, wx.NORMAL, wx.NORMAL) dc.SetFont(font) else: dc.SetFont(self.GetFont()) else: dc.SetBackground(wx.Brush(self.Editor.GetBackgroundColour())) dc.Clear() dc.BeginDrawing() if self.Scaling is not None and self.DrawGrid and not printing: dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(self.GridBrush) xstart, ystart = self.GetViewStart() window_size = self.Editor.GetClientSize() width, height = self.Editor.GetVirtualSize() width = int(max(width, xstart * SCROLLBAR_UNIT + window_size[0]) / self.ViewScale[0]) height = int(max(height, ystart * SCROLLBAR_UNIT + window_size[1]) / self.ViewScale[1]) dc.DrawRectangle(1, 1, width, height) if self.PageSize is not None and not printing: dc.SetPen(self.PagePen) xstart, ystart = self.GetViewStart() window_size = self.Editor.GetClientSize() if self.PageSize[0] != 0: for x in xrange(self.PageSize[0] - (xstart * SCROLLBAR_UNIT) % self.PageSize[0], int(window_size[0] / self.ViewScale[0]), self.PageSize[0]): dc.DrawLine(xstart * SCROLLBAR_UNIT + x + 1, int(ystart * SCROLLBAR_UNIT / self.ViewScale[0]), xstart * SCROLLBAR_UNIT + x + 1, int((ystart * SCROLLBAR_UNIT + window_size[1]) / self.ViewScale[0])) if self.PageSize[1] != 0: for y in xrange(self.PageSize[1] - (ystart * SCROLLBAR_UNIT) % self.PageSize[1], int(window_size[1] / self.ViewScale[1]), self.PageSize[1]): dc.DrawLine(int(xstart * SCROLLBAR_UNIT / self.ViewScale[0]), ystart * SCROLLBAR_UNIT + y + 1, int((xstart * SCROLLBAR_UNIT + window_size[0]) / self.ViewScale[1]), ystart * SCROLLBAR_UNIT + y + 1) # Draw all elements for comment in self.Comments.itervalues(): if comment != self.SelectedElement and (comment.IsVisible() or printing): comment.Draw(dc) for wire in self.Wires.iterkeys(): if wire != self.SelectedElement and (wire.IsVisible() or printing): if not self.Debug or not wire.GetValue(): wire.Draw(dc) if self.Debug: for wire in self.Wires.iterkeys(): if wire != self.SelectedElement and (wire.IsVisible() or printing) and wire.GetValue(): wire.Draw(dc) for block in self.Blocks.itervalues(): if block != self.SelectedElement and (block.IsVisible() or printing): block.Draw(dc) if self.SelectedElement is not None and (self.SelectedElement.IsVisible() or printing): self.SelectedElement.Draw(dc) if not printing: if self.Debug: self.InstanceName.Draw(dc) if self.rubberBand.IsShown(): self.rubberBand.Draw(dc) dc.EndDrawing()