wxPython - How to load a different panel into a frame

Discussion in 'Python' started by matthiasjanes, Jul 8, 2004.

  1. Dear all,

    I'm very new to wxPython. I'm using the wxglade ide to make a Gui.

    question is:

    Let's say I have a very simple frame with to menu entrys: LoadPanel1 and LoadPanel2

    ______________________loadpanel.py_________________________________

    #Begin:___Example_Code__

    #!/usr/bin/env python
    # generated by wxGlade 0.3.3 on Thu Jul 08 20:53:38 2004

    import wx

    class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrame.__init__
    kwds["style"] = wx.DEFAULT_FRAME_STYLE
    wx.Frame.__init__(self, *args, **kwds)

    # Menu Bar
    self.frame_1_menubar = wx.MenuBar()
    self.SetMenuBar(self.frame_1_menubar)
    wxglade_tmp_menu = wx.Menu()
    wxglade_tmp_menu.Append(10, "LoadPanel1", "LoadPanel1", wx.ITEM_NORMAL)
    wxglade_tmp_menu.Append(20, "LoadPanel2", "LoadPanel2", wx.ITEM_NORMAL)
    self.frame_1_menubar.Append(wxglade_tmp_menu, "Panel")
    # Menu Bar end

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

    #MANUEL ADDED CODE: Generate Bind Events Funktions

    self.Bind(wx.EVT_MENU, self.OnClickLoadPanel1, id=10)
    self.Bind(wx.EVT_MENU, self.OnClickLoadPanel2, id=20)

    #END MANUEL ADDED CODE: Generate Bind Events Funktions

    def __set_properties(self):
    # begin wxGlade: MyFrame.__set_properties
    self.SetTitle("frame_1")
    self.SetSize((400, 300))
    # end wxGlade

    def __do_layout(self):
    # begin wxGlade: MyFrame.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    self.SetAutoLayout(1)
    self.SetSizer(sizer_1)
    self.Layout()
    # end wxGlade


    #MANUEL ADDED CODE: Events Funktions
    def OnClickLoadPanel1(self, event):
    print "LoadPanel1"
    # someCode

    def OnClickLoadPanel2(self, event):
    print "LoadPanel2"
    # someCode

    #END OF MANUEL ADDED CODE: Events Funktions

    # end of class MyFrame


    class MyApp(wx.App):
    def OnInit(self):
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    self.SetTopWindow(frame_1)
    frame_1.Show(1)
    return 1

    # end of class MyApp

    if __name__ == "__main__":
    app = MyApp(0)
    app.MainLoop()

    # END:___Example_Code__

    _______________________________________________________

    Now How do I actually load a different Panel when I click the MenuEntries.

    Some simple working examples would be really greate.

    Thanks Matthias Janes
     
    matthiasjanes, Jul 8, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    924
    =?Utf-8?B?S2FubmFuLlYgW01DU0QubmV0XQ==?=
    Aug 3, 2005
  2. Fokke Nauta
    Replies:
    3
    Views:
    942
    Fokke Nauta
    Apr 29, 2009
  3. Arvin Portlock
    Replies:
    4
    Views:
    283
    Arvin Portlock
    Jul 12, 2004
  4. Rob Gordon

    Breaking a frame from a different frame

    Rob Gordon, Oct 17, 2004, in forum: Javascript
    Replies:
    0
    Views:
    139
    Rob Gordon
    Oct 17, 2004
  5. Jim Cobban
    Replies:
    0
    Views:
    124
    Jim Cobban
    Jul 31, 2005
Loading...

Share This Page