本文整理匯總了Python中wx.ScreenDC方法的典型用法代碼示例。如果您正苦於以下問題:Python wx.ScreenDC方法的具體用法?Python wx.ScreenDC怎麽用?Python wx.ScreenDC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wx
的用法示例。
在下文中一共展示了wx.ScreenDC方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ComputeFontScale
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import ScreenDC [as 別名]
def ComputeFontScale():
"""
Compute the font scale.
A global variable to hold the scaling from pixel size to point size.
"""
global FontScale
dc = wx.ScreenDC()
dc.SetFont(wx.Font(16, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
E = dc.GetTextExtent("X")
FontScale = 16/E[1]
del dc
# why do we do this here, causes a Sphinx build crash
#ComputeFontScale()
## fixme: This should probably be re-factored into a class
示例2: OnPaint
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import ScreenDC [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)
示例3: get_text_size
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import ScreenDC [as 別名]
def get_text_size(text, font):
dc = wx.ScreenDC()
dc.SetFont(font)
return dc.GetTextExtent(text)
示例4: saveImage
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import ScreenDC [as 別名]
def saveImage(canvas, filename):
s = wx.ScreenDC()
w, h = canvas.size.Get()
b = wx.EmptyBitmap(w, h)
m = wx.MemoryDCFromDC(s)
m.SelectObject(b)
m.Blit(0, 0, w, h, s, 70, 0)
m.SelectObject(wx.NullBitmap)
b.SaveFile(filename, wx.BITMAP_TYPE_PNG)
示例5: FontForLabels
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import ScreenDC [as 別名]
def FontForLabels(self, dc):
''' Return the default GUI font, scaled for printing if necessary. '''
font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
scale = dc.GetPPI()[0] / wx.ScreenDC().GetPPI()[0]
font.SetPointSize(scale*font.GetPointSize())
return font
示例6: GetBestSize
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import ScreenDC [as 別名]
def GetBestSize(self):
if not self.__radio_size:
dc = wx.ScreenDC()
dc.SetFont(compat.wx_SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT))
self.__radio_size = (3*dc.GetCharHeight())//2
label = self.GetLabel()
if label:
w, h = self.GetTextExtent(label)
w += self.__radio_size + self.GetCharWidth()
if h < self.__radio_size:
h = self.__radio_size
else:
w = h = self.__radio_size
return w, h