Search code examples
pythonfontswxpython

Applying a common font scheme to multiple objects in wxPython


Many times I will use the same font scheme for static text in a wxPython application. Currently I am making a SetFont() call for each static text object but that seems like a lot of unnecessary work. However, the wxPython demo and wxPython In Action book don't discuss this.

Is there a way to easily apply the same SetFont() method to all these text objects without making separate calls each time?


Solution

  • You can do this by calling SetFont on the parent window (Frame, Dialog, etc) before adding any widgets. The child widgets will inherit the font.