我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用wx.PaintDC()。
def OnPaint(self, event): "Window 'paint' event." dc = wx.PaintDC(self.imView) dc = wx.BufferedDC(dc) # paint a background just so it isn't *so* boring. dc.SetBackground(wx.Brush("WHITE")) dc.Clear() dc.SetBrush(wx.Brush("GREY", wx.CROSSDIAG_HATCH)) windowsize = self.imView.GetSizeTuple() dc.DrawRectangle(0, 0, windowsize[0], windowsize[1]) bmpX0 = 0 bmpY0 = 0 if self.bitmap is not None: if self.loadCentered: bmpX0 = (windowsize[0] - self.bitmap.Width) / 2 bmpY0 = (windowsize[1] - self.bitmap.Height) / 2 dc.DrawBitmap(self.bitmap, bmpX0, bmpY0, False) # ------------------------------------------------------------ # ImFrame.ConvertWXToPIL() # Expropriated from Andrea Gavana's # ShapedButton.py in the wxPython dist # ------------------------------------------------------------
def onPaintGL( self, event ): dc = wx.PaintDC( self.glArea ) self.glArea.SetCurrent(self.glContext) self.plot.fft_on = self.cbfftw.GetValue() if self.plot_reshape: apply(self.plot.reshape, self.plot_reshape) self.plot_reshape = False self.plot.display() self.glArea.SwapBuffers()
def onPaintGLCompass( self, event ): wx.PaintDC( self.CompassCalibration ) self.CompassCalibration.SetCurrent(self.compass_calibration_glContext) self.compass_calibration_plot.display() self.CompassCalibration.SwapBuffers()
def onPaintGLBoatPlot( self, event ): wx.PaintDC( self.CompassCalibration ) self.BoatPlot.SetCurrent(self.boat_plot_glContext) # stupid hack self.boat_plot.reshape(self.BoatPlot.GetSize().x, self.BoatPlot.GetSize().y) self.boat_plot.display(self.fusionQPose) self.BoatPlot.SwapBuffers()
def paintCallback(self, event): wx.PaintDC(self) self.SetCurrent(self.context) if not self.init: self.initGL() self.init = True self.onDraw()
def OnPaint(self, event): dc = wx.PaintDC(self) self.SetCurrent(self.context) # <== this was missing when I wrote the book in 2015... if not self.init: self.InitGL() self.init = True self.OnDraw()
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 OnPaint(self,event): event.Skip() dc = wx.PaintDC(self) if IsNotWX4(): self._Iren.GetRenderWindow().SetSize(self.GetSizeTuple()) else: self._Iren.GetRenderWindow().SetSize(self.GetSize()) if not self.__handle: self.__handle = self.GetHandle() self._Iren.GetRenderWindow().SetWindowInfo(str(self.__handle)) self.__has_painted = True self.Render()
def processPaintEvent(self, event): dc = wx.PaintDC(self) self.SetCurrent(self.context) if not self.GLinitialized: self.initGL() self.GLinitialized = True self.repaint()
def OnPaint(self, event): dc = wx.PaintDC(self) self.SetCurrent(self.context) #print(self, '=====', self.init) if not self.init: self.InitGL() self.init = True self.OnDraw()
def paint(self, ev): dc = wx.PaintDC(ev.GetEventObject()) if self.dirty: dc.Clear() self.dirty = False w = min(self.GetSize()[0], self.img.GetWidth()-self.x) h = min(self.GetSize()[1], self.img.GetHeight()-self.y) bx, by = (0, 0) if self.img.GetWidth() > self.GetSize()[0]: if self.x + self.GetSize()[0] > self.img.GetWidth(): self.x = self.img.GetWidth() - self.GetSize()[0] self.bx = 0 else: bx = int(.5*(self.GetSize()[0] - self.img.GetWidth())) self.x = 0 self.bx = bx if self.img.GetHeight() > self.GetSize()[1]: if self.y + self.GetSize()[1] > self.img.GetHeight(): self.y = self.img.GetHeight() - self.GetSize()[1] self.by = 0 else: by = int(.5*(self.GetSize()[1] - self.img.GetHeight())) self.y = 0 self.by = by # update if within 100px of borders if self.GetParent().GetParent().GetParent().options.get("exprender"): if ((self.x < 100 and self.ax > 0) or (self.y < 100 and self.ay > 0)) or ((self.x + w > 1900) or (self.y + h > 1900)): self.updatebracketimg() sub = wx.Rect(self.x, self.y, w, h) bimg = wx.BitmapFromImage(self.img.GetSubImage(sub)) dc.DrawBitmap(bimg, bx, by) if self.extimg: param0 = wx.BitmapFromImage(piltowx(self.extimg[0])) param1 = self.extimg[1]-self.x+self.bx param2 = self.extimg[2]-self.y+self.by dc.DrawBitmap(param0, param1, param2)
def _OnPaint(self, evt): #print '_OnPaint', self.GetClientSize(), self.GetBestSize() #if self._old_size == self.GetClientSize(): # return #self.SetBestSize(self.GetClientSize()) #dc = wx.PaintDC(self) #self._DrawSashes(dc) # New below - 28-12-2016 self._SizeWindows() #self._old_size = self.GetClientSize() # evt.Skip()