本文整理汇总了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