AttributeError:type object 'Panel' has no attribute 'setSizer'

In layoutComponents, the call should be self.SetSizer(grid1), not wx.Panel.setSizer(grid1)

···

----- Original Message ----
From: Rakesh Sinha rakesh.usenet@gmail.com
To: wxPython-users@lists.wxwidgets.org
Sent: Saturday, February 23, 2008 3:02:24 PM
Subject: [wxPython-users] AttributeError:type object ‘Panel’ has no attribute ‘setSizer’

Hi All -
I am playing around with my first Python code here.

import wx

class LoginPanel(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent, -1)
self.layoutComponents()

def layoutComponents(self):
    grid1    = wx.GridSizer(1, 1, 5, 50)
    wx.Panel.setSizer(grid1)

    self.lblUsername = wx.StaticText(self, -1, "Username", style=wx.ALIGN_RIGHT)

    grid1.Add(self.lblUsername)

class LoginFrame(wx.Frame):

def __init__(self, parent, ID, title):
    wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition, wx.Size(400, 250))

    print 'PI is approximately %5.7f.' % math.pi
    self.panel = LoginPanel(self)

    self.Center()
    self.Show()

When I run the program - I am getting the error -

“AttributeError: type object ‘Panel’ has no attribute ‘setSizer’”

I am seeing the API - it does seem to have a setSizer in wx.Window from which wx.Panel inherits.
Is there anything that I am missing here.


Never miss a thing. Make Yahoo your homepage.