TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item

SuSE 10.2

Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2

wx.version()

'2.8.6.0 (gtk2-unicode)'

···

----------------------------------------------------
I installed wxPython and dependencies from rpms. When I try to run
samples with a sizer, I get an exception:

~/wxPython-2.8.0.1/samples/mainloop> python mainloop.py
Traceback (most recent call last):
  File "mainloop.py", line 115, in <module>
    app = MyApp(False)
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 7823, in __init__
    self._BootstrapApp()
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 7420, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "mainloop.py", line 107, in OnInit
    frame = MyFrame(None, -1, "This is a test")
  File "mainloop.py", line 30, in __init__
    sizer.Add(wx.StaticText(panel, -1, "Size:"))
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 12452, in Add
    return _core_.Sizer_Add(*args, **kwargs)
TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item

Apparently I did something wrong or my Python interpreter is
incompatible, or something.
Thanks for any help.

SuSE 10.2
Python 2.5 (r25:51908, May 25 2007, 16:14:04)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2

>>> wx.version()
'2.8.6.0 (gtk2-unicode)'
----------------------------------------------------
I installed wxPython and dependencies from rpms. When I try to run
samples with a sizer, I get an exception:

    sizer.Add(wx.StaticText(panel, -1, "Size:"))
  File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
line 12452, in Add

Play around with the 'panel' argument to the StaticText. This is the parent
window for the control, and it's looking for the size stuff there.

You probably want the frame itself (usually 'self') instead of the panel.

If you're using a wx.Panel instance for your panel variable, then you're doing
everything just fine... but I got this error just the other day when I passed
the wrong object for the parent of the control.

I am getting this error when ever I run code from the "official"
samples and examples from WxPythonInAction book that has a sizer. That
code must have worked with some version of wxPython. One hit searching
GoogleGroups had a speculation from Robin Dunn that the message could
occur because of some problem with swig, but no fix nor course of
action was stated.

Thanks for the comeback.

···

On 2/19/08, Jim Carroll <jim@maplesong.com> wrote:

>
> SuSE 10.2
> Python 2.5 (r25:51908, May 25 2007, 16:14:04)
> [GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
>
> >>> wx.version()
> '2.8.6.0 (gtk2-unicode)'
> ----------------------------------------------------
> I installed wxPython and dependencies from rpms. When I try to run
> samples with a sizer, I get an exception:
>

> sizer.Add(wx.StaticText(panel, -1, "Size:"))
> File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py",
> line 12452, in Add

Play around with the 'panel' argument to the StaticText. This is the parent
window for the control, and it's looking for the size stuff there.

You probably want the frame itself (usually 'self') instead of the panel.

If you're using a wx.Panel instance for your panel variable, then you're doing
everything just fine... but I got this error just the other day when I passed
the wrong object for the parent of the control.