[英]wxPython Can't change font
I am trying to get the system font, modify it a bit and then set to a static text: 我正在尝试获取系统字体,对其进行一些修改,然后设置为静态文本:
panel = wx.Panel(self)
font = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(20)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
class_name_text = wx.StaticText(panel, label='Class name')
class_name_text.SetFont(font)
hbox1.Add(class_name_text)
vbox.Add(hbox1)
panel.SetSizer(vbox)
But apparently the text still remains with point size 12 (it looks that). 但是显然文本仍然保留磅值12(看起来像是)。 However, when i print the point size before and after changing it seems to be ok (12 before - 20 after).
但是,当我在更改前后打印磅值时,似乎没问题(12点之前-20点之后)。 A have tried to create my own font and changing its properties - in that case everything works.
A尝试创建我自己的字体并更改其属性-在这种情况下,一切正常。 What is wrong?
怎么了?
Well, thanks everyone! 好,谢谢大家! It seems that my system font, which
wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
returned, was a bit strange, because it didn't support any more sizes, but default. 看来我返回的系统字体
wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
有点奇怪,因为它不支持其他大小,而是默认大小。 When i changed font itself with SetFaceName
method, SetPointSize
began working. 当我使用
SetFaceName
方法更改字体本身时, SetPointSize
开始起作用。 So, the problem was in my system, probably in the system font particulary 因此,问题出在我的系统中,可能是系统字体特别
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.