TextCtrl.SetBackgroundColour() not working?

I've noticed that SetBackgroundColour() doesn't seem to have any effect on a TextCtrl. In my app, if I want to flag a bad value with a red background, I use the code:

txt.SetBackgroundColour((255, 0, 0))
txt.Refresh()

... but nothing changes. Is changing the background not supported for text controls?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

Ed Leafe wrote:

    I've noticed that SetBackgroundColour() doesn't seem to have any effect on a TextCtrl. In my app, if I want to flag a bad value with a red background, I use the code:

txt.SetBackgroundColour((255, 0, 0))
txt.Refresh()

... but nothing changes. Is changing the background not supported for text controls?

It depends on the platform and possibly on the active theme. For example some GTK themes do not allow the color to be changed for some widgets, and I think that single line textctrls can't have background color changes on OSX.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

In Suse,

Before you instatiate the app, try this:

  import os
        import platform

        if platform.system() == 'Linux':
            try:
                del os.environ['GTK_RC_FILES']
                del os.environ['GTK2_RC_FILES']
            except (ValueError, KeyError):
    pass

This will allow multiline textctrls to have different background colors,
but I still can't get single line textctrls to have different background
colors.

Eric

Ed Leafe wrote:

···

    I've noticed that SetBackgroundColour() doesn't seem to have any
effect on a TextCtrl. In my app, if I want to flag a bad value with a
red background, I use the code:

txt.SetBackgroundColour((255, 0, 0))
txt.Refresh()

... but nothing changes. Is changing the background not supported for
text controls?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com