我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用wx.BufferedPaintDC()。
def __init__(self,title): super(Frame,self).__init__(None,-1,title,style=wx.DEFAULT_FRAME_STYLE^wx.MAXIMIZE_BOX^wx.RESIZE_BORDER) self.colors = {0:(204,192,179),2:(238, 228, 218),4:(237, 224, 200),8:(242, 177, 121),16:(245, 149, 99),32:(246, 124, 95),64:(246, 94, 59),128:(237, 207, 114),256:(237, 207, 114),512:(237, 207, 114),1024:(237, 207, 114),2048:(237, 207, 114),4096:(237, 207, 114),8192:(237, 207, 114),16384:(237, 207, 114),32768:(237, 207, 114),65536:(237, 207, 114),131072:(237, 207, 114),262144:(237, 207, 114),524288:(237, 207, 114),1048576:(237, 207, 114),2097152:(237, 207, 114),4194304:(237, 207, 114),8388608:(237, 207, 114),16777216:(237, 207, 114)}#????????? self.setIcon() self.initGame() self.initBuffer() panel = wx.Panel(self) #?????? #------???? panel.Bind(wx.EVT_KEY_DOWN,self.onKeyDown) panel.SetFocus() #????? self.Bind(wx.EVT_SIZE,self.onSize) #use wx.BufferedPaintDC self.Bind(wx.EVT_PAINT,self.onPaint) self.Bind(wx.EVT_CLOSE,self.onClose) #???? #------ self.SetClientSize((505,720)) #?????? self.Center() #????? self.Show()
def __init__(self, parent, obj=None, mouse_callback=None, select_callback=None): wx.Panel.__init__(self, parent) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseDown) self.Bind(wx.EVT_LEFT_UP, self.OnMouseUp) self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.Bind(wx.EVT_RIGHT_UP, self.OnMouseUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_SIZE, self.OnSize) self.refresh_from_selection = False self.background_bitmap = None self.obj = obj self.selstart = self.selend = self.movepos = None self.moveSelection = False self.createSelection = False self.begin = 0 if self.obj is not None: self.chnls = len(self.obj) self.end = self.obj.getDur(False) else: self.chnls = 1 self.end = 1.0 self.img = [[]] self.mouse_callback = mouse_callback self.select_callback = select_callback if sys.platform == "win32" or sys.platform.startswith("linux"): self.dcref = wx.BufferedPaintDC else: self.dcref = wx.PaintDC self.setImage() #FL 02/10/2017 self.playCursorPos = 0
def OnPaint(self, event): if _plat.startswith('linux'): dc = wx.PaintDC(self) dc.Clear() elif _plat.startswith('darwin'): pass elif _plat.startswith('win'): if USE_BUFFERED_DC: dc = wx.BufferedPaintDC(self, self._Buffer) else: dc = wx.PaintDC(self) dc.DrawBitmap(self._Buffer, 0, 0) dc.Clear()
def repaint(self, event): """Handle wx repaint events. Notes: This should only be called from the wx event loop. If you need to manually trigger a repaint, call self.triggerRepaint instead to post an EVT_REPAINT event. """ wx.BufferedPaintDC(self, self.drawingBuffer)
def OnPaint(self, event): dc = wx.BufferedPaintDC(self, self._buffer)
def OnPaint(self, event): # All that is needed here is to draw the buffer to screen if self.last_PointLabel != None: self._drawPointLabel(self.last_PointLabel) # erase old self.last_PointLabel = None dc = wx.BufferedPaintDC(self.canvas, self._Buffer) if self._antiAliasingEnabled: try: dc = wx.GCDC(dc) except Exception: pass
def onPaint(self,event): dc = wx.BufferedPaintDC(self,self.buffer)
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()
def on_paint(self, event): wx.BufferedPaintDC(self, self.buffer)
def on_paint(self, event): wx.BufferedPaintDC(self, self.buffer) ''' cdc = wx.ClientDC(self) #cdc.BeginDrawing() if self.ips.roi != None: self.ips.roi.draw(cdc, self.to_panel_coor) if self.ips.mark != None: self.ips.mark.draw(cdc, self.to_panel_coor, cur=self.ips.cur, k = self.get_scale()) if self.ips.unit!=(1,'pix'): self.draw_ruler(cdc) #cdc.EndDrawing() '''
def OnPaint( self, event ): dc = wx.BufferedPaintDC( self ) # Draw the camera image if self.Camera.Connected: try: stream = self.Camera.Update() if stream != None: img = wx.ImageFromStream( stream ) bmp = wx.BitmapFromImage( img ) dc.DrawBitmap( bmp, 0, 0, True ) except: pass # If camera not connected draw blank white screen else: dc.SetBrush( wx.WHITE_BRUSH ) dc.DrawRectangle( -1, -1, CAMERA_SIZE_WIDTH, CAMERA_SIZE_HEIGHT ) # Draw the SocketClient match data if self.SocketClient != None: dc.SetTextForeground( HUD_COLOR ) # Clock min = self.SocketClient.MatchTime / 600 sec = int((self.SocketClient.MatchTime -(min * 600)) * .1) dc.DrawText( str(min).rjust(2, "0") + ":" + str(sec).rjust(2, "0"), TIME_POSITION_X, TIME_POSITION_Y ) # Scores for m in xrange(self.SocketClient.NumMechs): dc.DrawText( self.SocketClient.MechNames[m], SCORE_POSITION_X, SCORE_POSITION_Y1+(40*m) ) dc.DrawText( str(self.SocketClient.MechHP[m]), SCORE_POSITION_X, SCORE_POSITION_Y2+(40*m) ) # Draw the crosshairs
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()