+ def OnColour(self, evt):
+ colourData = wx.ColourData()
+ attr = rt.RichTextAttr()
+ attr.SetFlags(rt.TEXT_ATTR_TEXT_COLOUR)
+ if self.rtc.GetStyle(self.rtc.GetInsertionPoint(), attr):
+ colourData.SetColour(attr.GetTextColour())
+
+ dlg = wx.ColourDialog(self, colourData)
+ if dlg.ShowModal() == wx.ID_OK:
+ colourData = dlg.GetColourData()
+ colour = colourData.GetColour()
+ if colour:
+ if not self.rtc.HasSelection():
+ self.rtc.BeginTextColour(colour)
+ else:
+ r = self.rtc.GetSelectionRange()
+ attr.SetFlags(rt.TEXT_ATTR_TEXT_COLOUR)
+ attr.SetTextColour(colour)
+ self.rtc.SetStyle(r, attr)
+ dlg.Destroy()
+
+
+