wxPython继承字体
如何避免为每个标签编写:
static_text.SetFont(wx.Font(...))
static_text.SetForegroundColour(wx.Colour(...))
而是从父元素或其他元素继承字体?
How to avoid writing for each label:
static_text.SetFont(wx.Font(...))
static_text.SetForegroundColour(wx.Colour(...))
and instead inherit the font from parent element or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果更改父容器的字体,则其上的所有小部件都会获得该字体。例如,更改 Frame 实例的字体,静态文本和复选框中的字体会发生更改,而无需单独设置它们:
老实说,如果您想修改现有代码,但您无法访问编写 SetFont 行,那么您需要在编写这些类时考虑到这一点。显而易见的事情是在父类中的
__init__
外部的方法中设置 Font,以便在将从限制访问类继承的类中覆盖它If you change the font of the parent container you get that font for all the widgets on it. For example changing the font for the Frame instance, font gets changed in the static text and the checkbox without the need to set them separately:
Afaik if you want to modify existing code you can not access to write the SetFont line, then you need these classes to have been written with that in mind. The obvious thing would be to have the Font set in a method outside
__init__
in the parent class in order to overwrite it in your class that will be inheriting from the restricted-access class尝试这样的事情:
Try something like that: