Python wx.WHITE_BRUSH Examples
The following are 9
code examples of wx.WHITE_BRUSH().
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: custom_widget.py From wxGlade with MIT License | 6 votes |
def on_paint(self, event): dc = wx.PaintDC(self.widget) dc.SetBrush(wx.WHITE_BRUSH) dc.SetPen(wx.BLACK_PEN) dc.SetBackground(wx.WHITE_BRUSH) dc.Clear() w, h = self.widget.GetClientSize() dc.DrawLine(0, 0, w, h) dc.DrawLine(w, 0, 0, h) text = _('Custom Widget: %s') % self.instance_class tw, th = dc.GetTextExtent(text) x = (w - tw)//2 y = (h - th)//2 dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 0, wx.TRANSPARENT)) dc.DrawRectangle(x-1, y-1, tw+2, th+2) dc.DrawText(text, x, y)
Example #2
Source File: Widget.py From meerk40t with MIT License | 6 votes |
def process_draw(self, gc): if self.scene.device.draw_mode & DRAW_MODE_GRID != 0: return device = self.scene.device if device is not None: wmils = device.bed_width * MILS_IN_MM hmils = device.bed_height * MILS_IN_MM else: wmils = 320 * MILS_IN_MM hmils = 220 * MILS_IN_MM background = self.background if background is None: gc.SetBrush(wx.WHITE_BRUSH) gc.DrawRectangle(0, 0, wmils, hmils) elif isinstance(background, int): gc.SetBrush(wx.Brush(wx.Colour(swizzlecolor(background)))) gc.DrawRectangle(0, 0, wmils, hmils) else: gc.DrawBitmap(background, 0, 0, wmils, hmils) if self.grid is None: self.calculate_grid() starts, ends = self.grid gc.SetPen(wx.BLACK_PEN) gc.StrokeLineSegments(starts, ends)
Example #3
Source File: CameraInteface.py From meerk40t with MIT License | 5 votes |
def on_update_buffer(self, event=None): if self.frame_bitmap is None: return # Need the bitmap to refresh. dm = self.device.draw_mode dc = wx.MemoryDC() dc.SelectObject(self._Buffer) dc.Clear() w, h = dc.Size if dm & DRAW_MODE_FLIPXY != 0: dc.SetUserScale(-1, -1) dc.SetLogicalOrigin(w, h) dc.SetBackground(wx.WHITE_BRUSH) gc = wx.GraphicsContext.Create(dc) gc.SetTransform(wx.GraphicsContext.CreateMatrix(gc, ZMatrix(self.matrix))) gc.PushState() gc.DrawBitmap(self.frame_bitmap, 0, 0, self.image_width, self.image_height) if not self.device.camera_correction_perspective: if self.perspective is None: self.perspective = [0, 0], \ [self.image_width, 0], \ [self.image_width, self.image_height], \ [0, self.image_height] gc.SetPen(wx.BLACK_DASHED_PEN) gc.StrokeLines(self.perspective) gc.StrokeLine(self.perspective[0][0], self.perspective[0][1], self.perspective[3][0], self.perspective[3][1]) gc.SetPen(wx.BLUE_PEN) for p in self.perspective: half = CORNER_SIZE / 2 gc.StrokeLine(p[0] - half, p[1], p[0] + half, p[1]) gc.StrokeLine(p[0], p[1] - half, p[0], p[1] + half) gc.DrawEllipse(p[0] - half, p[1] - half, CORNER_SIZE, CORNER_SIZE) gc.PopState() if dm & DRAW_MODE_INVERT != 0: dc.Blit(0, 0, w, h, dc, 0, 0, wx.SRC_INVERT) gc.Destroy() del dc
Example #4
Source File: FBD_Objects.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def Draw(self, dc): Graphic_Element.Draw(self, dc) dc.SetPen(MiterPen(wx.BLACK)) dc.SetBrush(wx.WHITE_BRUSH) if getattr(dc, "printing", False): name_size = dc.GetTextExtent(self.Name) executionorder_size = dc.GetTextExtent(str(self.ExecutionOrder)) else: name_size = self.NameSize executionorder_size = self.ExecutionOrderSize text_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y + (self.Size[1] - name_size[1]) // 2) # Draw a rectangle with the variable size dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) # Draw variable name dc.DrawText(self.Name, text_pos[0], text_pos[1]) # Draw connectors if self.Input: self.Input.Draw(dc) if self.Output: self.Output.Draw(dc) if self.ExecutionOrder != 0: # Draw variable execution order dc.DrawText(str(self.ExecutionOrder), self.Pos.x + self.Size[0] - executionorder_size[0], self.Pos.y + self.Size[1] + 2) if not getattr(dc, "printing", False): DrawHighlightedText(dc, self.Name, self.Highlights, text_pos[0], text_pos[1]) # ------------------------------------------------------------------------------- # Function Block Diagram Connector # -------------------------------------------------------------------------------
Example #5
Source File: FBD_Objects.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def Draw(self, dc): Graphic_Element.Draw(self, dc) dc.SetPen(MiterPen(wx.BLACK)) dc.SetBrush(wx.WHITE_BRUSH) if getattr(dc, "printing", False): name_size = dc.GetTextExtent(self.Name) else: name_size = self.NameSize # Draw a rectangle with the connection size with arrows inside dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) arrowsize = min(self.Size[1] // 2, (self.Size[0] - name_size[0] - 10) // 2) dc.DrawLine(self.Pos.x, self.Pos.y, self.Pos.x + arrowsize, self.Pos.y + self.Size[1] // 2) dc.DrawLine(self.Pos.x + arrowsize, self.Pos.y + self.Size[1] // 2, self.Pos.x, self.Pos.y + self.Size[1]) dc.DrawLine(self.Pos.x + self.Size[0] - arrowsize, self.Pos.y, self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] // 2) dc.DrawLine(self.Pos.x + self.Size[0], self.Pos.y + self.Size[1] // 2, self.Pos.x + self.Size[0] - arrowsize, self.Pos.y + self.Size[1]) # Draw connection name text_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y + (self.Size[1] - name_size[1]) // 2) dc.DrawText(self.Name, text_pos[0], text_pos[1]) # Draw connector if self.Connector: self.Connector.Draw(dc) if not getattr(dc, "printing", False): DrawHighlightedText(dc, self.Name, self.Highlights, text_pos[0], text_pos[1])
Example #6
Source File: SFC_Objects.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def Draw(self, dc): Graphic_Element.Draw(self, dc) if self.Value: if self.Forced: dc.SetPen(MiterPen(wx.CYAN)) else: dc.SetPen(MiterPen(wx.GREEN)) elif self.Forced: dc.SetPen(MiterPen(wx.BLUE)) else: dc.SetPen(MiterPen(wx.BLACK)) dc.SetBrush(wx.WHITE_BRUSH) if getattr(dc, "printing", False): name_size = dc.GetTextExtent(self.Name) else: name_size = self.NameSize # Draw two rectangles for representing the step dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) if self.Initial: dc.DrawRectangle(self.Pos.x + 2, self.Pos.y + 2, self.Size[0] - 3, self.Size[1] - 3) # Draw step name name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y + (self.Size[1] - name_size[1]) // 2) dc.DrawText(self.Name, name_pos[0], name_pos[1]) # Draw input and output connectors if self.Input: self.Input.Draw(dc) if self.Output: self.Output.Draw(dc) if self.Action: self.Action.Draw(dc) if not getattr(dc, "printing", False): DrawHighlightedText(dc, self.Name, self.Highlights, name_pos[0], name_pos[1]) # ------------------------------------------------------------------------------- # Sequencial Function Chart Transition # -------------------------------------------------------------------------------
Example #7
Source File: charmapdlg.py From trelby with GNU General Public License v2.0 | 4 votes |
def OnPaint(self, event): dc = wx.BufferedPaintDC(self, self.screenBuf) size = self.GetClientSize() dc.SetBrush(wx.WHITE_BRUSH) dc.SetPen(wx.WHITE_PEN) dc.DrawRectangle(0, 0, size.width, size.height) dc.SetPen(wx.BLACK_PEN) dc.SetTextForeground(wx.BLACK) for y in range(self.rows + 1): util.drawLine(dc, self.offset, self.offset + y * self.cellSize, self.cols * self.cellSize + 1, 0) for x in range(self.cols + 1): util.drawLine(dc, self.offset + x * self.cellSize, self.offset, 0, self.rows * self.cellSize) dc.SetFont(self.normalFont) for y in range(self.rows): for x in range(self.cols): i = y * self.cols + x if i < len(self.chars): util.drawText(dc, self.chars[i], x * self.cellSize + self.offset + self.cellSize // 2 + 1, y * self.cellSize + self.offset + self.cellSize // 2 + 1, util.ALIGN_CENTER, util.VALIGN_CENTER) y = self.offset + self.rows * self.cellSize pad = 5 if self.selected: code = ord(self.selected) self.drawCharBox(dc, "Selected:", self.selected, self.offset, y + pad, 75) c = util.upper(self.selected) if c == self.selected: c = util.lower(self.selected) if c == self.selected: c = None if c: self.drawCharBox(dc, "Opposite case:", c, self.offset + 150, y + pad, 110) dc.SetFont(self.smallFont) dc.DrawText("Character code: %d" % code, 360, y + pad) if code == 32: dc.DrawText("Normal space", 360, y + pad + 30) elif code == 160: dc.DrawText("Non-breaking space", 360, y + pad + 30) else: dc.SetFont(self.smallFont) dc.DrawText("Click on a character to select it.", self.offset, y + pad)
Example #8
Source File: FBD_Objects.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def Draw(self, dc): Graphic_Element.Draw(self, dc) dc.SetPen(self.Pen) dc.SetBrush(wx.WHITE_BRUSH) dc.SetTextForeground(self.Colour) if getattr(dc, "printing", False): name_size = dc.GetTextExtent(self.Name) type_size = dc.GetTextExtent(self.Type) executionorder_size = dc.GetTextExtent(str(self.ExecutionOrder)) else: name_size = self.NameSize type_size = self.TypeSize executionorder_size = self.ExecutionOrderSize # Draw a rectangle with the block size dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) # Draw block name and block type name_pos = (self.Pos.x + (self.Size[0] - name_size[0]) // 2, self.Pos.y - (name_size[1] + 2)) type_pos = (self.Pos.x + (self.Size[0] - type_size[0]) // 2, self.Pos.y + 5) dc.DrawText(self.Name, name_pos[0], name_pos[1]) dc.DrawText(self.Type, type_pos[0], type_pos[1]) # Draw inputs and outputs connectors for input in self.Inputs: input.Draw(dc) for output in self.Outputs: output.Draw(dc) if self.ExecutionOrder != 0: # Draw block execution order dc.DrawText(str(self.ExecutionOrder), self.Pos.x + self.Size[0] - executionorder_size[0], self.Pos.y + self.Size[1] + 2) if not getattr(dc, "printing", False): DrawHighlightedText(dc, self.Name, self.Highlights.get("name", []), name_pos[0], name_pos[1]) DrawHighlightedText(dc, self.Type, self.Highlights.get("type", []), type_pos[0], type_pos[1]) # ------------------------------------------------------------------------------- # Function Block Diagram Variable # -------------------------------------------------------------------------------
Example #9
Source File: SFC_Objects.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def Draw(self, dc): Graphic_Element.Draw(self, dc) if self.Value: dc.SetPen(MiterPen(wx.GREEN)) else: dc.SetPen(MiterPen(wx.BLACK)) dc.SetBrush(wx.WHITE_BRUSH) colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]] # Draw plain rectangle for representing the action block dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1) dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y, self.Pos.x + colsize[0], self.Pos.y + self.Size[1]) dc.DrawLine(self.Pos.x + colsize[0] + colsize[1], self.Pos.y, self.Pos.x + colsize[0] + colsize[1], self.Pos.y + self.Size[1]) line_size = self.GetLineSize() for i, action in enumerate(self.Actions): if i != 0: dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, self.Pos.x + self.Size[0], self.Pos.y + i * line_size) qualifier_size = dc.GetTextExtent(action.qualifier) if action.duration != "": qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) // 2, self.Pos.y + i * line_size + line_size // 2 - qualifier_size[1]) duration_size = dc.GetTextExtent(action.duration) duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) // 2, self.Pos.y + i * line_size + line_size // 2) dc.DrawText(action.duration, duration_pos[0], duration_pos[1]) else: qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) // 2, self.Pos.y + i * line_size + (line_size - qualifier_size[1]) // 2) dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1]) content_size = dc.GetTextExtent(action.value) content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) // 2, self.Pos.y + i * line_size + (line_size - content_size[1]) // 2) dc.DrawText(action.value, content_pos[0], content_pos[1]) if action.indicator != "": indicator_size = dc.GetTextExtent(action.indicator) indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) // 2, self.Pos.y + i * line_size + (line_size - indicator_size[1]) // 2) dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1]) if not getattr(dc, "printing", False): action_highlights = self.Highlights.get(i, {}) for name, attribute_highlights in action_highlights.iteritems(): if name == "qualifier": DrawHighlightedText(dc, action.qualifier, attribute_highlights, qualifier_pos[0], qualifier_pos[1]) elif name == "duration": DrawHighlightedText(dc, action.duration, attribute_highlights, duration_pos[0], duration_pos[1]) elif name in ["reference", "inline"]: DrawHighlightedText(dc, action.value, attribute_highlights, content_pos[0], content_pos[1]) elif name == "indicator": DrawHighlightedText(dc, action.indicator, attribute_highlights, indicator_pos[0], indicator_pos[1]) # Draw input connector self.Input.Draw(dc)