Thanks! I didn't think what the wx.TE_RICH2 style flag might imply about behavior. I'll work with your suggestion for using the Default attributes.
Hank
Robin Dunn wrote:
···
Hank Knox wrote:
I have a question about setting the background colour of an ExpandoTextCtrl:
I am setting the background of the control based on the validity of the user input - if the input is valid, the colour should be the same as the underlying panel, otherwise it's set to another colour. To set the background to the underlying panel background colour, I set its colour to wx.NullColour. As the attached demo shows, the ExpandoTextCtrl does not behave the same way as the basic TextCtrl: doing ExpandoTextCtrl.SetBackgroundColour(wx.NullColour) makes the background black, whereas TextCtrl.SetBackgroundColour(wx.NullColour) sets it to white. Since the Expando is a subclass of TextCtrl, I don't see why the behavior is different.The expando uses the wx.TE_RICH2 style flag so it ends up using a different native widget. Apparently that widget is not responding to the set background message in the same way.
You can do something like this instead:
da = self.exp.GetDefaultAttributes()
self.exp.SetBackgroundColour(da.colBg)