Bryan Oakley
Bryan Oakley

Reputation: 386010

wxpython: how to get StyledTextCtrl to render all text in monospace font?

What's the right way to use a monospaced font for all text in a StyledTextCtrl? I'm using it over the simpler TextCtrl because I need the FindText() functionality which is oddly missing from a standard text control.

I'd also like to avoid hard-coding a specific font face, and instead rely on the monospace font defined by the system if possible.

Upvotes: 2

Views: 1592

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386010

I think this is what I'm looking for. Can anybody improve upon this?

font = wx.Font(9, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
face = font.GetFaceName()
size = font.GetPointSize()
self.out.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT,"face:%s,size:%d" % (face, size))

Upvotes: 2

Related Questions