Hi all,
Wxpython 2.8 under linux.
Here is a piece of code which changes the background colour of a
selection or start new background colour if at the end of the text.
This works fine. However, when I save the content of the buffer or I
refresh the content of the richtextctrl, the background colour is
lost ...
Does anyone know why ? could I miss a flag somewhere in the declaraiton
of the richtextctrl ?
def OnSelectBackGroundColor(self, evt):
dlg = wx.ColourDialog(self)
dlg.GetColourData().SetChooseFull(True)
MyTextAttr=rt.TextAttrEx()
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetColourData()
color=data.GetColour().Get()
if self.window_2.HasSelection():
r = self.window_2.GetSelectionRange()
if data:
MyTextAttr.SetFlags(rt.TEXT_ATTR_BACKGROUND_COLOUR)
MyTextAttr.SetBackgroundColour( color)
self.window_2.SetStyleEx(r, MyTextAttr)
else :
MyTextAttr.SetFlags(rt.TEXT_ATTR_BACKGROUND_COLOUR)
MyTextAttr.SetBackgroundColour( color)
self.window_2.BeginStyle(MyTextAttr)
dlg.Destroy()