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

Hello,

I just built the latest release version of wxPython from source and I keep getting this error when I try to run some code that worked before. When I try to run the following sample code:

import wx

class MyFrame
(wx.Frame):
def
init(self, parent, ID
, title):
wx.Frame
.init(self, parent,
ID, title, size=(300
, 250))

   panel1

= wx.Panel(self,
-1, style=wx.SUNKEN_BORDER
)
panel2 = wx.Panel
(self,-1, style=
wx.SUNKEN_BORDER)

   panel1

.SetBackgroundColour(“BLUE”)
panel2
.SetBackgroundColour(“RED”)

   box = wx.BoxSizer(wx

.VERTICAL)
box.Add(
panel1, 2, wx.EXPAND
)
box.Add(panel2,
1, wx.EXPAND)

   self.SetAutoLayout(True)

   self.SetSizer(box)

   self.Layout()

app = wx.PySimpleApp(
)
frame = MyFrame(None,
-1, “Sizer Test”)

frame.Show()
app.
MainLoop()

I get this error:

Traceback (most recent call last):
File “/tmp/ixarka/test2.py”, line 24, in
frame = MyFrame(None, -1, “Sizer Test”)
File “/tmp/ixarka/test2.py”, line 15, in init

box.Add(panel1, 2, wx.EXPAND)

File “/home/ixarka/lib/python2.5/site-packages/wx-2.8-gtk2-ansi/wx/_core.py”, line 12475, in Add
return core.Sizer_Add(*args, **kwargs)
TypeError: wx.Window
, wx.Sizer, wx.Size, or (w,h) expected for item

If I try to run a simpler wx example (without sizers), like this:

import wx
app =
wx.PySimpleApp()
frame =
wx.Frame(None, -
1, “Just one child”, size=(
250,150))
button =
wx.Button(frame, -
1, “This is resized”)
frame.
Show()
app.MainLoop(
)

Everything works fine. Any idea what could be going on?

Thanks.

A quick followup:

I just confirmed that this only happens when I build with gcc/g++ 4.1.1. If I build with 3.4.6, then that sample code runs fine. I’m doing these builds on a 64-bit system.

···

On 1/14/08, ixarka@gmail.com ixarka@gmail.com wrote:

Hello,

I just built the latest release version of wxPython from source and I keep getting this error when I try to run some code that worked before. When I try to run the following sample code:

import wx

class MyFrame (wx.Frame):

def init(self, parent, ID , title):

   wx.Frame .__init__(self, parent, ID, title

, size=(300 , 250))

   panel1 = wx

.Panel(self, -1, style=wx.SUNKEN_BORDER )

   panel2 = wx.Panel (self,-1, style=

wx.SUNKEN_BORDER)

   panel1 .SetBackgroundColour("BLUE"

)
panel2 .SetBackgroundColour(“RED”)

   box =

wx.BoxSizer(wx .VERTICAL)
box.Add(
panel1, 2, wx.EXPAND )
box.Add(panel2
, 1, wx.EXPAND)

   self.SetAutoLayout(

True)
self.SetSizer(box)
self.Layout
()

app = wx.PySimpleApp( )
frame
= MyFrame(None, -1, “Sizer Test”)
frame.
Show()
app. MainLoop()

I get this error:

Traceback (most recent call last):
File “/tmp/ixarka/test2.py”, line 24, in
frame = MyFrame(None, -1, “Sizer Test”)
File “/tmp/ixarka/test2.py”, line 15, in init
box.Add(panel1, 2, wx.EXPAND)
File “/home/ixarka/lib/python2.5/site-packages/wx-2.8-gtk2-ansi/wx/_core.py”, line 12475, in Add
return core.Sizer_Add(*args, **kwargs)
TypeError: wx.Window
, wx.Sizer, wx.Size, or (w,h) expected for item

If I try to run a simpler wx example (without sizers), like this:

import wx
app = wx.PySimpleApp()
frame
= wx.Frame(None, - 1, “Just one child”, size
=( 250,150))
button = wx.Button(
frame, - 1, “This is resized”)
frame. Show()

app.MainLoop( )

Everything works fine. Any idea what could be going on?

Thanks.