문제

I have a wxPython application (using 2.8), built with python 2.7.

Is there a way to change the font for the whole application ? I mean, I would like to change font for any wx.StaticText, wx.Button, wx.Combo for every widget that shows "text". Do I need to use the c++ wrapper (wxWidgets), if yes, how ?

도움이 되었습니까?

해결책

You should be able to use inheritance to set all the widgets to the same font, according to this thread:

The idea is to set the font on the top level parent, such as the wx.Panel. Then all the children will inherit that font.

This older thread mentions that you need to set the font BEFORE you create the widgets. If you need to change the font AFTER, then you'll have to iterate over the child widgets, setting their font individually yourself. I would use parent.GetChildren() to get all or most of them.

다른 팁

Here is code to change the overall wxPython font.

wx.Frame.__init__(self, *args, **kwargs)
self.top_panel = wx.Panel(self)
self.top_panel.SetFont(wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, 'Consolas'))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top