本文整理汇总了Python中wx.PaintDC方法的典型用法代码示例。如果您正苦于以下问题:Python wx.PaintDC方法的具体用法?Python wx.PaintDC怎么用?Python wx.PaintDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.PaintDC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gui_repaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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)
示例2: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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)
示例3: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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()
示例4: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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
示例5: DotifyOnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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()
示例6: on_paint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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)
示例7: on_paint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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)
示例8: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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)
示例9: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
def OnPaint(self, event):
dc = wx.PaintDC(self)
dc.SetFont(self.font)
dc.SetTextForeground(self.textColor)
if self.pic.Ok():
dc.DrawBitmap(self.pic, 0, 0, False)
util.drawText(dc, "Version %s" % (misc.version),
200, 170, util.ALIGN_RIGHT)
util.drawText(dc, "http://www.trelby.org/", 200, 185, util.ALIGN_RIGHT)
if self.quote:
dc.SetFont(self.sourceFont)
dc.DrawText(self.quote.source, 50, 280)
dc.SetFont(self.quoteFont)
for i,line in enumerate(self.quote.lines):
x = 10
y = 260 - (len(self.quote.lines) - i - 1) * 17
if i == 0:
dc.DrawText(u"“", x - 5, y)
if i == (len(self.quote.lines) - 1):
line = line + u"”"
dc.DrawText(line, x, y)
示例10: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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.
示例11: processPaintEvent
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
def processPaintEvent(self, event):
dc = wx.PaintDC(self)
self.SetCurrent(self.context)
if not self.GLinitialized:
self.initGL()
self.GLinitialized = True
self.repaint()
示例12: _on_paint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
def _on_paint(self, event):
"""Push the MemoryDC bitmap to the displayed PaintDC."""
dc = wx.PaintDC(self)
dc.Blit(0, 0, self.dc_w, self.dc_h, self.mdc, 0, 0)
示例13: _onPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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()
示例14: _onPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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()
示例15: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import PaintDC [as 别名]
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()
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:9,代码来源:import_OpenGL_cube_and_cone.py