I am trying to set the font without using the fontdialog box in the new RichTextCtrl module.
What I have tried so far is below (with some extra to show where I am trying to modify the code). My attempts start at line 28 of the latest release of Docs and Demos.
Can anyone help me? I have tried to find my way using the wxWidgets manual, but it seems that things are just a bit different between the sample and the manual.
My first attempts are marked by #'s below.
Thanks, thom
self.rtc.BeginParagraphSpacing(0, 20)
self.rtc.BeginAlignment(rt.TEXT_ALIGNMENT_CENTRE)
self.rtc.BeginBold()
# Thom Modified Starting Here
self.rtc.BeginFontSize(14)
self.rtc.WriteText("This is Greek")
self.rtc.EndFontSize()
self.rtc.Newline()
fontData = wx.FontData()
fontData.EnableEffects(False)
attr = rt.RichTextAttr()
attr.SetFlags(rt.TEXT_ATTR_FONT)
if self.rtc.GetStyle(0, attr):
fontData.SetInitialFont(attr.CreateFont())
font = 'SymbolPS' #'4-KeyTimesRoman' #fontData.GetChosenFont()
if font:
attr.SetFlags(rt.TEXT_ATTR_FONT)
attr.SetFont(font)
self.rtc.SetStyle(r, attr)
#attr = rt.RichTextAttr()
#attr.SetFlags(rt.TEXT_ATTR_FONT)
#attr.SetFont('SymbolPS') #CharacterStyleName
#self.rtc.SetStyle((0,8),attr)
# Thom's Modifications Ended Here
self.rtc.BeginFontSize(14)
self.rtc.WriteText("Velcome to wxRichTextCtrl, a wxWidgets control for editing and presenting styled text and images")
self.rtc.EndFontSize()
self.rtc.Newline()