[wxpython-users] Trouble when Creating a Panel

David Anderson zerty.david at gmail.com
Tue May 20 18:11:01 PDT 2008


It's not multiple panels, Its just changing panels on the same window,
changing the screen Got it?
And

David Anderson wrote:

>    It shows the derived one fine, But I'm trying to show these panels
>    through the menu, So On the init of my MainApp class I create a
>    self.panel =3D Frame(self,-1)
>

this would create a Frame, not a Panel...

I Mis typed
Take a look at the code:
class MainWindow(wx.Frame):
    def __init__(self, parent, id, title =3D "Finarta Order Search"):
        wx.Frame.__init__(self, parent, id, title, size =3D (1024,740),styl=
e =3D
wx.CLOSE_BOX |
                           wx.CAPTION |wx.SYSTEM_MENU|
wx.MINIMIZE_BOX|wx.CLOSE_BOX)
        self.buildMenu()
        self.Centre()
        self.Fit()
        self.SetSize((1024,740))
        self.Show(True)
    def buildMenu(self):
                menubar =3D wx.MenuBar()
                home =3D wx.Menu()
                exit =3D wx.MenuItem(home, wx.ID_ANY, 'Exit')
                home.AppendItem(exit)
                menubar.Append(home, '&Home')
                order =3D wx.Menu()
                add =3D wx.MenuItem(order, wx.ID_ANY, "Add")
                view =3D wx.MenuItem(order, wx.ID_ANY, "View")
                edit =3D wx.MenuItem(order, wx.ID_ANY, "Edit")
                search =3D wx.MenuItem(order, wx.ID_ANY, "Search")
                order.AppendItem(add)
                order.AppendItem(view)
                order.AppendItem(edit)
                order.AppendItem(search)
                menubar.Append(order, '&Order')
                self.Bind(wx.EVT_MENU, self.OnAddOrder, add)
                self.Bind(wx.EVT_MENU, self.OnViewOrder, view)
                self.Bind(wx.EVT_MENU, self.OnEditOrder, edit)
                self.Bind(wx.EVT_MENU, self.OnSearchOrder, search)

 def OnAddOrder(self, evt):
        self.DestroyChildren()
        apanel =3D AddOrder(self,-1)
        self.Centre()
        self.Fit()
        self.SetSize((1024,740))
        self.Show(True)

    def OnEditOrder(self, evt):
        self.DestroyChildren()
        apanel =3D EditOrder(self, -1)
        self.Centre()
        self.Fit()
        self.SetSize((1024,740))
        self.Show(True)

    def OnViewOrder(self, evt):
        self.DestroyChildren()
        apanel =3D ViewOrder(self, -1)
        self.Centre()
        self.Fit()
        self.SetSize((1024,740))
        self.Show(True)

    def OnSearchOrder(self, evt):
        self.DestroyChildren()
        apanel =3D OrderSearch(self, -1)
        self.Centre()
        self.Fit()
        self.SetSize((1024,740))
        self.Show(True)


That's it =3D)

On Tue, May 20, 2008 at 10:02 PM, C M <cmpython at gmail.com> wrote:

> On Tue, May 20, 2008 at 7:33 PM, David Anderson <zerty.david at gmail.com>
> wrote:
> > Hi, I have a Class Named MainnApp, Whcih is derived from wx.Frame, There
> I
> > call any of my subclasses that are derived from wx.panels, The thing is,
> if
> > I call like this:
> > self.Panel =3D DerivedPanel(self, -1)
> >
> > It shows the derived one fine, But I'm trying to show these panels
> through
> > the menu, So On the init of my MainApp class I create a self.panel =3D
> > Frame(self,-1)
> >
> > and on the Menu's event handler I do like this
> > self.Panel =3D DerivedPanel(self, -1)
> > The thing is... Its putting everything of the menu on the top left corn=
er
> > above everything, Doesn'1t create as when I call it on the init method
> > What am I doing wrong?
> > Hope you understand my problem
> > =3D)
>
> By the way, I'm not really sure what layout you are going for, but
> since you want multiple panels shown...have you tried using any of the
> "book" controls (wxNotebook, etc.) found in the Demo?  That's what
> they are for, and might simplify things for you.
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200805=
20/d26aff30/attachment.htm


More information about the wxpython-users mailing list