Frage

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 ?

War es hilfreich?

Lösung

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.

Andere Tipps

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'))
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top