Problems with wxNotebook and SetBackgroundColour

I'm trying to write an application that has a wxNotebook as the main widget. I create extra pages as I go, and add them to the notebook.

I've been having trouble setting the background colour for the notebook. I found a post in the past that on XP if you have themes enabled, it will set the wxPanel background at the time you add the panel to the notebook. So I moved the SetBackgroundColour() to after the page has been created and added. And that works fine for XP and win2k. However, it isn't working under Fedora Core 2. I'm using GTK2 to do the development.

What I think I found is that if I call SetBackgroundColour() in __init__, it then gets overridden by the AddPage(). But if I call it again, it doesn't set the colour if the colour is the same as it was earlier.

The only way I've found to get it to work, is to call SetBackgroundColour() with a color other than wxColour(0,0,0), and then let the page be shown, then call SetBackgroundColour(wxColour(0,0,0)), and then Refresh()

It seems like it is trying to be smart about not setting the colour if it hasn't changed. But it doesn't realize that the colour really has changed.

Another problem I've been having is that in GTK2, I have to do the following:

self.mainNotebook.Show(False)
panel = wxPanel(parent=self.mainNotebook, ....)
self.mainNotebook.AddPage(panel, ...)
panel.SetBackgroundColour(wxColour(10,10,10))

self.mainNotebook.SetSelection(newPageNum)
panel.SetBackgroundColour(wxColour(0,0,0))
self.mainNotebook.Show(True)

If I don't Show(False) I get:
Gtk-CRITICAL **: file gtkwidget.c: line 2221 (gtk_widget_realize): assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

Is there a better way to work around this without hiding my main widget?

Everything works fine under Win2K and WinXP.

John
=:->

I'm using wxWidgets 2.5.1.5 on Fedora Core 2, and 2.4.2.4 on winXP &

win2K

John Meinel wrote:

> I'm using wxWidgets 2.5.1.5 on Fedora Core 2, and 2.4.2.4 on winXP & win2K

Please update to 2.5.2.8, all of these issues have been fixed (or at least improved) recently.

ยทยทยท

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