views:

70

answers:

1

I have a RichTextCtrl, which I've modified to accept HTML input. The HTML parsing code needs to be able to increase and decrease the font size as it gets tags like <font size="-1">, but I can't work out how to get the control's default font size to adjust.
I tried the following (where self is my RichTextCtrl):

fred = wx.richtext.RichTextAttr()
self.GetStyle(0,fred)
print fred.GetFontSize()

However, the final instruction fails, because GetStyle turns fred into a TextAttrEx and so I get AttributeError: 'TextAttrEx' object has no attribute 'GetFontSize'. Am I missing a vastly easier way of getting the default font size?

A: 

Worked this out. Before any data is written to the control:

self.defaultstyle = wx.richtext.RichTextAttr()
self.GetStyle(self.GetInsertionPoint(), self.defaultstyle)
self.defaultsize = self.defaultstyle.GetFont().GetPointSize()
Sam