[wxPython] Re: wxGenButton error in Demo 2.3.2.1

Hi,

I have commented out line 154 and it works OK, but I am using standard
windows colours.

My guess is that you should be using

self.SetBackgroundColour(colour)

instead of

wxWindow.SetBackgroundColour(self, colour)

but you have already over-ridden the SetBackgroundColour method, so it will
not work (self refers back to the wxGenButton method rather than to the
wxWindow method through inheritance).

Regards,

Gordon Williams

···

----- Original Message -----
From: "Gordon Williams" <g_will@cyberus.ca>
To: "wxPython List" <wxpython-users@lists.wxwindows.org>
Sent: Tuesday, January 29, 2002 8:44 PM
Subject: wxGenButton error in Demo 2.3.2.1

This is it.

Regards,

Gordon Williams

Traceback (most recent call last):
  File "G:\Program

Files\Python22\Lib\site-packages\wxPython\demo\Main.py",

line
330, in OnSelChanged
    self.RunDemo(itemText)
  File "G:\Program

Files\Python22\Lib\site-packages\wxPython\demo\Main.py",

line
362, in RunDemo
    self.window = module.runTest(self, self.nb, self) ###
  File "G:\Program
Files\Python22\Lib\site-packages\wxPython\demo\GenericButtons
.py", line 98, in runTest
    win = TestPanel(nb, log)
  File "G:\Program
Files\Python22\Lib\site-packages\wxPython\demo\GenericButtons
.py", line 21, in __init__
    b = wxGenButton(self, -1, 'Hello', (10,65))
  File "G:\PROGRA~1\PYTHON22\lib\site-packages\wxPython\lib\buttons.py",
line 78
, in __init__
    self.InitColours()
  File "G:\PROGRA~1\PYTHON22\lib\site-packages\wxPython\lib\buttons.py",
line 14
2, in InitColours
    self.SetBackgroundColour(faceClr)
  File "G:\PROGRA~1\PYTHON22\lib\site-packages\wxPython\lib\buttons.py",
line 15
4, in SetBackgroundColour
    wxWindow.SetBackgroundColour(self, colour)
TypeError: unbound method SetBackgroundColour() must be called with

wxWindow

ins
tance as first argument (got wxGenButton instance instead)

I have commented out line 154 and it works OK, but I am using standard
windows colours.

My guess is that you should be using

self.SetBackgroundColour(colour)

instead of

wxWindow.SetBackgroundColour(self, colour)

Actually the fix is to use wxControl. There was a change to how methods are
searched for in base classes in Python 2.2 that screwed it up. wxControl is
the immediate ancestor, but wxWindow (the grandparent class) is where the
method is defined... Go figure.

(BTW, the same (or related) change also screwed up how wxPython looks for
methods to use as virtual method callbacks. That one took me three solid
weeks to figure out a workaround for...)

···

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