Python wx.PaintDC() Examples
The following are 30
code examples of wx.PaintDC().
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: chronolapse.py From chronolapse with MIT License | 6 votes |
def OnPaint(self, evt): # this doesnt appear to work at all... width,height = self.GetSizeTuple() # get drawing canvas dc = wx.PaintDC(self) dc.SetPen(wx.Pen(wx.Colour(0,0,255,255))) dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220))) # build rect size = max(2, (width-10)*self.progress) rect = wx.Rect(5,8, size ,5) # draw rect dc.Clear() dc.BeginDrawing() dc.DrawRoundedRectangleRect(rect, 2) dc.EndDrawing()
Example #3
Source File: chronolapsegui.py From chronolapse with MIT License | 6 votes |
def OnPaint(self, evt): # this doesnt appear to work at all... width,height = self.GetSizeTuple() # get drawing shit dc = wx.PaintDC(self) dc.SetPen(wx.Pen(wx.Colour(0,0,255,255))) dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220))) # build rect size = max(2, (width-10)*self.progress) rect = wx.Rect(5,8, size ,5) # draw rect dc.Clear() dc.BeginDrawing() dc.DrawRoundedRectangleRect(rect, 2) dc.EndDrawing() # end wxGlade
Example #4
Source File: gui.py From superpaper with MIT License | 6 votes |
def OnPaint(self, evt): dc = wx.PaintDC(self) # Hiding bitmap widgets, probably unnecessary # for st_bmp in self.preview_img_list: # st_bmp.Hide() # Canvas drawing if (not self.config_mode and not self.use_multi_image and self.current_preview_images): # print("Drawing canvas: ", self.config_mode, not self.use_multi_image, self.current_preview_images) self.draw_canvas(dc) else: # print("Skipping canvas: ", self.config_mode, not self.use_multi_image, self.current_preview_images) self.draw_canvas(dc, False) # Display drawing if self.config_mode: self.draw_shapes(dc) else: self.draw_st_bmps(dc)
Example #5
Source File: __init__.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def DotifyOnPaint(self, event): self.dc = wx.PaintDC(self) self.dc.SetFont(self.GetFont()) width = self.GetSize().width str_width = self.dc.GetTextExtent(self._string)[0] max_width = self.dc.GetTextExtent(self.label)[0] if width >= max_width: self._string = self.label elif width != str_width: string = self.dotdotdot(self.label, width, max_width) self._string = string wx.StaticText.SetLabel(self, self._string) event.Skip()
Example #6
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #7
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #8
Source File: spacer.py From wxGlade with MIT License | 6 votes |
def on_paint(self, event): dc = wx.PaintDC(self.widget) brush = wx.TheBrushList.FindOrCreateBrush( self.widget.GetBackgroundColour() ) dc.SetBrush(brush) dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 1, wx.SOLID)) dc.SetBackground(brush) dc.Clear() w, h = self.widget.GetClientSize() dc.DrawLine(0, 0, w, h) dc.DrawLine(w, 0, 0, h) text = _('Spacer') 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 #9
Source File: backend_wx.py From coffeegrindsize with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #10
Source File: backend_wx.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #11
Source File: backend_wx.py From CogAlg with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #12
Source File: WordWrapRenderer.py From bookhub with MIT License | 6 votes |
def OnPaint(self, evt): dc = wx.PaintDC(self) inset = (20, 20, 20, 20) rect = [inset[0], inset[1], self.GetSize().width-(inset[0]+inset[2]), self.GetSize().height-(inset[1]+inset[3])] # Calculate exactly how high the wrapped is going to be and put a frame around it. dc.SetFont(self.font) dc.SetPen(wx.RED_PEN) rect[3] = WordWrapRenderer.CalculateHeight(dc, self.text, rect[2]) dc.DrawRectangle(*rect) WordWrapRenderer.DrawString(dc, self.text, rect, wx.ALIGN_LEFT) #WordWrapRenderer.DrawTruncatedString(dc, self.text, rect, wx.ALIGN_CENTER_HORIZONTAL,s ellipse=wx.CENTER) #bmp = wx.EmptyBitmap(rect[0]+rect[2], rect[1]+rect[3]) #mdc = wx.MemoryDC(bmp) #mdc.SetBackground(wx.Brush("white")) #mdc.Clear() #mdc.SetFont(self.font) #mdc.SetPen(wx.RED_PEN) #rect[3] = WordWrapRenderer.CalculateHeight(mdc, self.text, rect[2]) #mdc.DrawRectangle(*rect) #WordWrapRenderer.DrawString(mdc, self.text, rect, wx.ALIGN_LEFT) #del mdc #dc = wx.ScreenDC() #dc.DrawBitmap(bmp, 20, 20)
Example #13
Source File: backend_wx.py From twitter-stock-recommendation with MIT License | 6 votes |
def gui_repaint(self, drawDC=None, origin='WX'): """ Performs update of the displayed image on the GUI canvas, using the supplied wx.PaintDC device context. The 'WXAgg' backend sets origin accordingly. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if not drawDC: # not called from OnPaint use a ClientDC drawDC = wx.ClientDC(self) # following is for 'WX' backend on Windows # the bitmap can not be in use by another DC, # see GraphicsContextWx._cache if wx.Platform == '__WXMSW__' and origin == 'WX': img = self.bitmap.ConvertToImage() bmp = img.ConvertToBitmap() drawDC.DrawBitmap(bmp, 0, 0) else: drawDC.DrawBitmap(self.bitmap, 0, 0)
Example #14
Source File: backend_wx.py From coffeegrindsize with MIT License | 5 votes |
def _onPaint(self, evt): """ Called when wxPaintEvt is generated """ DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) drawDC.Destroy()
Example #15
Source File: SampleDCApp.py From advancedpython3 with GNU General Public License v3.0 | 5 votes |
def on_paint(self, event): """set up the device context (DC) for painting""" dc = wx.PaintDC(self) dc.DrawLine(10, 10, 60, 20) dc.DrawRectangle(20, 40, 40, 20) dc.DrawText("Hello World", 30, 70) dc.DrawCircle(130, 40, radius=15)
Example #16
Source File: edit_base.py From wxGlade with MIT License | 5 votes |
def on_paint(self, event): "Handle paint request and draw hatched lines onto the window" #if not self.sizer: return # in deletion dc = wx.PaintDC(self.widget) self._draw_background(dc)
Example #17
Source File: params.py From admin4 with Apache License 2.0 | 5 votes |
def OnPaintButton(self, evt): dc = wx.PaintDC(self.button) dc.SetBrush(wx.TRANSPARENT_BRUSH) if self.IsEnabled(): dc.SetPen(wx.BLACK_PEN) else: dc.SetPen(wx.GREY_PEN) size = self.button.GetSize() dc.DrawRectangle(0, 0, size.width, size.height)
Example #18
Source File: CustomWidgets.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def OnPaint(self, event): dc = wx.PaintDC(self) rect = self.GetClientRect() if self.border: dc.SetPen(wx.Pen(self.border_color)) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.DrawRectangle(0, 0, rect.width, rect.height) rect = wx.Rect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2) _ScaleBlit(self.buffer, dc, rect)
Example #19
Source File: backend_wx.py From CogAlg with MIT License | 5 votes |
def _onPaint(self, evt): """ Called when wxPaintEvt is generated """ DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) drawDC.Destroy()
Example #20
Source File: CustomWidgets.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def OnPaint(self, event): dc = wx.PaintDC(self) _ScaleBlit(self.buffer, dc, self.GetClientRect(), strip_border=1)
Example #21
Source File: __init__.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def OnPaint(self, event): dc = wx.PaintDC(self) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) if self.bitmap: dc.DrawBitmap(self.bitmap, 0, 0, True)
Example #22
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, evt): dc = wx.PaintDC(self) dc.DrawBitmap(self.bmp, 0, 0, True)
Example #23
Source File: backend_wx.py From ImageFusion with MIT License | 5 votes |
def _onPaint(self, evt): """ Called when wxPaintEvt is generated """ DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) evt.Skip()
Example #24
Source File: backend_wx.py From twitter-stock-recommendation with MIT License | 5 votes |
def _onPaint(self, evt): """ Called when wxPaintEvt is generated """ DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) drawDC.Destroy()
Example #25
Source File: wx_viewer.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def OnPaint(self, event=None): wx.PaintDC(self) if self.context is not None: self.SetCurrent(self.context) else: self.SetCurrent() if self.GL_uninitialised: gl.glViewport(0, 0, self.w, self.h) self.InitGL() self.GL_uninitialised = 0 self.OnRedrawGL(event)
Example #26
Source File: import_OpenGL_cube_and_cone.py From Python-GUI-Programming-Cookbook-Second-Edition with MIT License | 5 votes |
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()
Example #27
Source File: misc.py From trelby with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, event): dc = wx.PaintDC(self) w, h = self.GetClientSizeTuple() br = wx.Brush(self.GetBackgroundColour()) dc.SetBrush(br) dc.DrawRectangle(0, 0, w, h) # Custom "exit fullscreen" button for our tab bar. Used so that we have # full control over the button's size.
Example #28
Source File: misc.py From trelby with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, event): cfgGui = self.getCfgGui() dc = wx.PaintDC(self) w, h = self.GetClientSizeTuple() dc.SetBrush(cfgGui.tabNonActiveBgBrush) dc.SetPen(cfgGui.tabBorderPen) dc.DrawRectangle(0, 0, w, h) off = (h - self.fsImage.GetHeight()) // 2 dc.DrawBitmap(self.fsImage, off, off)
Example #29
Source File: misc.py From trelby with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, event): cfgGui = self.getCfgGui() cy = (TAB_BAR_HEIGHT - 1) // 2 xoff = 5 dc = wx.PaintDC(self) w, h = self.GetClientSizeTuple() dc.SetBrush(cfgGui.tabBarBgBrush) dc.SetPen(cfgGui.tabBarBgPen) dc.DrawRectangle(0, 0, w, h) dc.SetPen(cfgGui.tabTextPen) dc.SetTextForeground(cfgGui.tabTextColor) pageText = "Page %d / %d" % (self.page, self.pageCnt) dc.SetFont(self.font) util.drawText(dc, pageText, MyStatus.WIDTH - xoff, cy, util.ALIGN_RIGHT, util.VALIGN_CENTER) s1 = "%s [Enter]" % self.enterNext s2 = "%s [Tab]" % self.tabNext x = MyStatus.X_ELEDIVIDER + xoff dc.DrawText(s1, x, 0) dc.DrawText(s2, x, cy) x = xoff s = "%s" % self.elemType dc.SetFont(self.elementFont) util.drawText(dc, s, x, cy, valign = util.VALIGN_CENTER) dc.SetPen(cfgGui.tabBorderPen) dc.DrawLine(0, h-1, w, h-1) for x in (MyStatus.X_ELEDIVIDER, 0): dc.DrawLine(x, 0, x, h-1)
Example #30
Source File: misc.py From trelby with GNU General Public License v2.0 | 5 votes |
def OnPaint(self, event): dc = wx.PaintDC(self) # dialog that shows two lists of script names, allowing user to choose one # from both. stores indexes of selections in members named 'sel1' and # 'sel2' when OK is pressed. 'items' must have at least two items.