Python wx.BufferedPaintDC() Examples
The following are 18
code examples of wx.BufferedPaintDC().
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: chapter2.py From OpenCV-Computer-Vision-Projects-with-Python with MIT License | 6 votes |
def NextFrame(self, event): # acquire new frame, ignore timestamp frame,_ = freenect.sync_get_depth() # clip max depth to 1023, convert to 8-bit grayscale np.clip(frame, 0, 2**10 - 1, frame) frame >>= 2 frame = frame.astype(np.uint8) # segment hand, detect number of fingers, return # annotated RGB image frame = self.ProcessFrame(frame) # update buffer and paint self.bmp.CopyFromBuffer(frame) deviceContext = wx.BufferedPaintDC(self.pnl) deviceContext.DrawBitmap(self.bmp, 0, 0) del deviceContext
Example #2
Source File: main.py From python-examples with MIT License | 5 votes |
def OnPaint(self, event): dc = wx.BufferedPaintDC(self) dc.DrawBitmap(self.bmp, 0, 0)
Example #3
Source File: pyslip.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def OnPaint(self, event): """Paint the canvas to the screen.""" # Blit the front buffer to the screen wx.BufferedPaintDC(self, self.buffer)
Example #4
Source File: Viewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def OnPaint(self, event): dc = self.GetLogicalDC(True) self.DoDrawing(dc) wx.BufferedPaintDC(self.Editor, dc.GetAsBitmap()) if self.Debug: DebugViewer.RefreshNewData(self) event.Skip()
Example #5
Source File: CameraInteface.py From meerk40t with MIT License | 5 votes |
def on_paint(self, event): try: wx.BufferedPaintDC(self.display_camera, self._Buffer) except RuntimeError: pass
Example #6
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, event=None): wx.BufferedPaintDC(self, self._buffer)
Example #7
Source File: ShowOSD.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, dummyEvent=None): wx.BufferedPaintDC(self, self.bitmap)
Example #8
Source File: CustomWidgets.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def OnPaint(self, event): dc = wx.BufferedPaintDC(self, self.buffer)
Example #9
Source File: gui.py From opencv-python-blueprints with GNU General Public License v3.0 | 5 votes |
def _on_paint(self, event): """ This method draws the camera frame stored in the bitmap self.bmp onto the panel self.pnl. Make sure self.pnl exists and is at least the size of the camera frame. This method is called whenever an event wx.EVT_PAINT is triggered. """ # read and draw buffered bitmap deviceContext = wx.BufferedPaintDC(self.pnl) deviceContext.DrawBitmap(self.bmp, 0, 0)
Example #10
Source File: live_demo.py From mr_saliency with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, evt): dc = wx.BufferedPaintDC(self) dc.DrawBitmap(self.bmp, 0, 0)
Example #11
Source File: live_demo.py From mr_saliency with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, evt): dc = wx.BufferedPaintDC(self) dc.DrawBitmap(self.bmp, 0, 0) # self.display(sal,style('image'))
Example #12
Source File: squaremap.py From pyFileFixity with MIT License | 5 votes |
def OnPaint(self, event): dc = wx.BufferedPaintDC(self, self._buffer)
Example #13
Source File: gui.py From OpenCV-Computer-Vision-Projects-with-Python with MIT License | 5 votes |
def _on_paint(self, event): """ This method draws the camera frame stored in the bitmap self.bmp onto the panel self.pnl. Make sure self.pnl exists and is at least the size of the camera frame. This method is called whenever an event wx.EVT_PAINT is triggered. """ # read and draw buffered bitmap deviceContext = wx.BufferedPaintDC(self.pnl) deviceContext.DrawBitmap(self.bmp, 0, 0)
Example #14
Source File: widget_meter.py From RF-Monitor with GNU General Public License v2.0 | 4 votes |
def __on_paint(self, _event): pdc = wx.BufferedPaintDC(self) try: dc = wx.GCDC(pdc) except: dc = pdc w, h = self.GetClientSize() font = self.GetFont() font.SetPixelSize((0, h - (TICK_SIZE_MAJ * 2))) dc.SetFont(font) dc.SetPen(wx.Pen(wx.WHITE)) dc.SetBrush(wx.Brush(wx.WHITE)) dc.DrawRectangle(0, 0, w, h) colour = '#4DDB4D' if self._value >= self._threshold else '#FF4D4D' dc.SetPen(wx.Pen(colour)) dc.SetBrush(wx.Brush(colour)) x = self.__scale_x(self._value, w) dc.DrawRectangle(0, 0, x, h) colour = wx.Colour(0x80, 0x80, 0xFF, 128) dc.SetPen(wx.Pen(colour, 2)) dc.SetBrush(wx.Brush(colour)) x = round(self.__scale_x(self._threshold, w)) dc.DrawPolygon([(x - THRES_SIZE, 0), (x + THRES_SIZE, 0), (x, THRES_SIZE)]) dc.DrawPolygon([(x - THRES_SIZE, h), (x + THRES_SIZE, h), (x, h - THRES_SIZE)]) dc.DrawLine(x, THRES_SIZE, x, h - THRES_SIZE) if self._noise is not None: dc.SetPen(wx.Pen('#8080FF', 1)) x = self.__scale_x(self._noise, w) dc.DrawRectangle(0, TICK_SIZE_MAJ * 3 / 2., x, h - (TICK_SIZE_MAJ * 3)) colour = wx.Colour(0x4d, 0x4d, 0x4d) dc.SetPen(wx.Pen(colour)) dc.SetTextForeground(colour) ticks = range(LEVEL_MIN, LEVEL_MAX, 10) for tick in ticks: if tick not in [LEVEL_MIN, LEVEL_MAX]: x = self.__scale_x(tick, w) dc.DrawLine(x, 0, x, TICK_SIZE_MAJ) dc.DrawLine(x, h, x, h - TICK_SIZE_MAJ) label = str(tick) tW, tH = dc.GetTextExtent(label) dc.DrawText(label, x - tW / 2, (h - tH) / 2) ticks = range(LEVEL_MIN, LEVEL_MAX, 1) for tick in ticks: if tick not in [LEVEL_MIN, LEVEL_MAX]: x = self.__scale_x(tick, w) dc.DrawLine(x, 0, x, TICK_SIZE_MIN) dc.DrawLine(x, h, x, h - TICK_SIZE_MIN)
Example #15
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 #16
Source File: LogViewer.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def OnPaint(self, event): dc = wx.BufferedPaintDC(self) dc.Clear() dc.BeginDrawing() gc = wx.GCDC(dc) width, height = self.GetClientSize() gc.SetPen(wx.Pen(wx.NamedColour("GREY"), 3)) gc.SetBrush(wx.GREY_BRUSH) gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 - 3)) gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 + 3)) gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 + 3)) gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 - 3)) thumb_rect = self.GetThumbRect() exclusion_rect = wx.Rect(thumb_rect.x, thumb_rect.y, thumb_rect.width, thumb_rect.height) if self.Parent.IsMessagePanelTop(): exclusion_rect.y, exclusion_rect.height = width, exclusion_rect.y + exclusion_rect.height - width if self.Parent.IsMessagePanelBottom(): exclusion_rect.height = height - width - exclusion_rect.y if exclusion_rect != thumb_rect: colour = wx.NamedColour("LIGHT GREY") gc.SetPen(wx.Pen(colour)) gc.SetBrush(wx.Brush(colour)) gc.DrawRectangle(exclusion_rect.x, exclusion_rect.y, exclusion_rect.width, exclusion_rect.height) gc.SetPen(wx.GREY_PEN) gc.SetBrush(wx.GREY_BRUSH) gc.DrawPolygon(ArrowPoints(wx.TOP, width, width, 0, 0)) gc.DrawPolygon(ArrowPoints(wx.BOTTOM, width, width, 0, height)) gc.DrawRectangle(thumb_rect.x, thumb_rect.y, thumb_rect.width, thumb_rect.height) dc.EndDrawing() event.Skip()
Example #17
Source File: pyslip.py From dials with BSD 3-Clause "New" or "Revised" License | 4 votes |
def GetNearestPointInLayer(self, layer, pt): """Determine if clicked location selects a point in layer data. layer layer object we are looking in pt click geo location (lon, lat) or screen (x, y) Return None (no selection) or ((x, y), data) of closest point. """ # TODO: speed this up? Do we need to?? # http://en.wikipedia.org/wiki/Kd-tree # would need to create kd-tree in AddLayer() (ptx, pty) = pt res = None dist = 9999999.0 # more than possible if layer.map_rel: for p in layer.data: (x, y, _, _, _, _, _, data) = p d = (x - ptx) * (x - ptx) + (y - pty) * (y - pty) if d < dist: dist = d res = ((x, y), data) if dist <= layer.delta: return res else: for p in layer.data: dc = wx.BufferedPaintDC(self, self.buffer) (dc_w, dc_h) = dc.GetSize() dc_w2 = dc_w / 2 # noqa; lgtm; self-modifying code dc_h2 = dc_h / 2 # noqa; lgtm; self-modifying code dc_h -= 1 dc_w -= 1 (x, y, place, _, _, x_off, y_off, pdata) = p exec(self.point_view_placement[place]) d = (x - ptx) * (x - ptx) + (y - pty) * (y - pty) if d < dist: dist = d res = ((x, y), pdata) if dist <= layer.delta: return res return None
Example #18
Source File: pyslip.py From dials with BSD 3-Clause "New" or "Revised" License | 4 votes |
def GetBoxSelPointsInLayer(self, layer, p1, p2): """Get list of points inside box. layer reference to layer object we are working on p1 one corner point of selection box p2 opposite corner point of selection box We have to figure out which corner is which. Return a list of (lon, lat) of points inside box. Return None (no selection) or list [((lon, lat), data), ...] of points inside the selection box. """ # TODO: speed this up? Do we need to?? # get canonical box limits (p1x, p1y) = p1 (p2x, p2y) = p2 lx = min(p1x, p2x) # left x coord rx = max(p1x, p2x) ty = max(p1y, p2y) # top y coord by = min(p1y, p2y) # get a list of points inside the selection box result = [] if layer.map_rel: for p in layer.data: (x, y, _, _, _, _, _, pdata) = p if lx <= x <= rx and by <= y <= ty: result.append(((x, y), pdata)) else: for p in layer.data: dc = wx.BufferedPaintDC(self, self.buffer) (dc_w, dc_h) = dc.GetSize() dc_w2 = dc_w / 2 # noqa; lgtm; self-modifying code dc_h2 = dc_h / 2 # noqa; lgtm; self-modifying code dc_h -= 1 dc_w -= 1 (x, y, place, _, _, x_off, y_off, pdata) = p exec(self.point_view_placement[place]) if lx <= x <= rx and by <= y <= ty: result.append(((x, y), pdata)) return result