Odd problem between running program from command vs. PythonWin GUI

I have a really odd problem that is perplexing me. I am using wxPython
2.5.1 with ActiveState Python 2.3 with the PythonWin GUI.

Here is the code in question:
        [much setup code goes before here]
        self.SetAutoLayout(1)
        print "Setting background to green"
        self.SetBackgroundColour(wx.GREEN)

I am trying to set the background color of a wxPanel (that gets attached
to a wxNotebook). Running the program from a command prompt shows the
print statement, but no color change. Running the program from the
PythonWin IDE shows the print statement, and the color change!

I am going to trace through the code in more detail, but thought I would
post to see if anyone else had experienced something like this before.

Thanks!
Hubert Hickman
hubert@tconl.com

Hubert Hickman wrote:

I have a really odd problem that is perplexing me. I am using wxPython
2.5.1 with ActiveState Python 2.3 with the PythonWin GUI.

Here is the code in question:
        [much setup code goes before here]
        self.SetAutoLayout(1)
        print "Setting background to green"
        self.SetBackgroundColour(wx.GREEN)

i've been playing with that. it works for me. but i haven't used the Colour objects (i infer that wx.GREEN is just an alias for
wx.Colour(0, 255, 0) ). I've just used the literal labels:

# SetBackgroundColour does not force immed. repaint
karma.SetBackgroundColour('White')
karma.Refresh()

The wxWindows doc for wxWindow::SetBackgroundColour says you may need to follow with 'Refresh()' or 'Clear()'.

I've been using Refresh. I don't remember whether I proved it necessary or not.

Hubert Hickman wrote:

I have a really odd problem that is perplexing me. I am using wxPython
2.5.1 with ActiveState Python 2.3 with the PythonWin GUI.

Here is the code in question:
        [much setup code goes before here]
        self.SetAutoLayout(1)
        print "Setting background to green"
        self.SetBackgroundColour(wx.GREEN)

I am trying to set the background color of a wxPanel (that gets attached
to a wxNotebook). Running the program from a command prompt shows the
print statement, but no color change. Running the program from the
PythonWin IDE shows the print statement, and the color change!

You are running on XP, right?

On XP when themes are enabled for the App then wxWidgets will post-process pages added to a notebook to change their background colours to match the theme settings. When you run from the command line you are using python.exe or pythonw.exe for which wxPython's installer installed a manifest file that turns on the use of the themed common conrols for those .exe's. When you run from within PythonWin you are using Pythonwin.exe which does not have a manifest file and so it is using the old version of the common controls, hence no theme support and so wxWidgets leaves the notebook pages alone.

If you want to ignore the theme bg colour for notebook pages then you need to set the colour after it has been added to the notebook.

···

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