[wxPython] wxGenButton failure [wxPython 2.3.2.1, Python 2.2]

My apologies if this is a known issue, but I didn't find it mentioned in a
search of the mailing list archive.

I'm starting to test out a migration from a Python 1.5.2/wxPython 2.2.x
platform to the latest 2.3.2.1 under Python 2.2, and I've run into a problem
with wxGenButton in wxPython.lib.buttons. Originally I thought it was due
to my use of the hybrid build, but now I've tried the standard and it
happens as well.

Specifically any attempt to instantiate a wxGenButton fails while trying to
establish its colors, with the traceback ending up at:

File "d:\pkg\python22\lib\site-packages\wxPython\lib\buttons.py", line 154,
in SetBackgroundColour
    wxWindow.SetBackgroundColour(self, colour)
TypeError: unbound method SetBackgroundColour() must be called with wxWindow
instance as first argument (got wxGenButton instance instead)

Originally I detected this in my own code (which subclasses wxGenButton),
but it occurs if you try to run the wxPython demo for the generic buttons as
well.

Now, it seems to me that since wxGenButton is a subclass of wxControl, which
itself is derived from wxWindow, that it should be valid, no? But in any
event, this seems to break wxGenButton completely.

Any ideas on how to possibly work around this - I tend to use wxGenButton in
a number of my applications, so this is a drag :slight_smile:

-- David

/-----------------------------------------------------------------------\
\ David Bolen \ E-mail: db3l@fitlinxx.com /
  > FitLinxx, Inc. \ Phone: (203) 708-5192 |
/ 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
\-----------------------------------------------------------------------/

Specifically any attempt to instantiate a wxGenButton fails while trying

to

establish its colors, with the traceback ending up at:

File "d:\pkg\python22\lib\site-packages\wxPython\lib\buttons.py", line

154,

in SetBackgroundColour
    wxWindow.SetBackgroundColour(self, colour)
TypeError: unbound method SetBackgroundColour() must be called with

wxWindow

instance as first argument (got wxGenButton instance instead)

Make the following change to buttons.py. The rules for method lookup have
changed a bit in Python 2.2, although I wouldn't have thought that this
particular usage would break... (I did run into some nastyness at the C API
level though. Take a look at my helpers.cpp if you're curious.)

retrieving revision 1.8
diff -c -r1.8 buttons.py
*** buttons.py 2001/12/06 20:00:27 1.8
--- buttons.py 2002/01/02 18:56:27

···

***************
*** 151,157 ****

      def SetBackgroundColour(self, colour):
! wxWindow.SetBackgroundColour(self, colour)

          # Calculate a new set of highlight and shadow colours based on
          # the new background colour. Works okay if the colour is dark...
--- 151,157 ----

      def SetBackgroundColour(self, colour):
! wxControl.SetBackgroundColour(self, colour)

          # Calculate a new set of highlight and shadow colours based on
          # the new background colour. Works okay if the colour is dark...

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