Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8898881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:43:24+00:00 2026-06-15T00:43:24+00:00

I’m following the tutorial from http://wiki.wxpython.org/Getting%20Started and I’m busy with the notebook example. Here,

  • 0

I’m following the tutorial from http://wiki.wxpython.org/Getting%20Started and I’m busy with the notebook example. Here, multiple panels are added into one frame. It uses the following example code:

class ExamplePanel(wx.Panel):
    def __init__(self, parent):
        [...]

app = wx.App(False)
frame = wx.Frame(None, title="Demo with Notebook")
nb = wx.Notebook(frame)

nb.AddPage(ExamplePanel(nb), "Absolute Positioning")
nb.AddPage(ExamplePanel(nb), "Page Two")
nb.AddPage(ExamplePanel(nb), "Page Three")
frame.Show()
app.MainLoop()

This works for me. However, instead of using the standard wx.Frame() for the frame I want to use my own one (the frame works if I only use one panel):

class ExampleFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self,parent, title = title)
        panel = wx.Panel(self)
        self.CreateStatusBar()
        # Setting up the menu.
        filemenu = wx.Menu()

        #wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets
        menuAbout = filemenu.Append(wx.ID_ABOUT, "&About", " Information about this program")
        menuExit = filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program")

        # Creating the menubar
        menuBar = wx.MenuBar()
        menuBar.Append(filemenu, "&miP3") # Adding filemenu to the MenuBar
        self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content.

        # Set events
        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.Bind(wx.EVT_MENU, self.OnExit, menuExit)     

    def OnAbout(self, event):
        # A message dialoge box with an OK button. wx.OK is a sandard ID in wxWidgets
        dlg = wx.MessageDialog(self, "Author: Niek de Klein", "About miP3")
        dlg.ShowModal() # show it
        dlg.Destroy() # finally destroy it when finished

    def OnExit(self, eevent):
        self.Close(True) # close the frame

app = wx.App(False)
frame = frame = ExampleFrame(None, title="Demo with Notebook")
nb = wx.Notebook(frame)

nb.AddPage(ExamplePanel(nb), "Absolute Positioning")
nb.AddPage(ExamplePanel(nb), "Page Two")
nb.AddPage(ExamplePanel(nb), "Page Three")
frame.Show()
app.MainLoop()

How can I add multiple panels to my custom frame?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:43:26+00:00Added an answer on June 15, 2026 at 12:43 am

    You could do something like this:

    #!/usr/bin/env python
    import wx
    import wx.grid
    
    class ExampleFrame ( wx.Frame ):
    
        def __init__( self, parent ):
            wx.Frame.__init__ ( self, parent)
    
            self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
    
            bSizer1 = wx.BoxSizer( wx.VERTICAL )
    
            self.Panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
            bSizer2 = wx.BoxSizer( wx.VERTICAL )
    
            self.nb = wx.Notebook( self.Panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
    
            bSizer2.Add( self.nb, 1, wx.EXPAND |wx.ALL, 5 )
    
            self.Panel.SetSizer( bSizer2 )
            self.Panel.Layout()
            bSizer2.Fit( self.Panel )
            bSizer1.Add( self.Panel, 1, wx.EXPAND |wx.ALL, 0 )
    
            self.SetSizer( bSizer1 )
            self.Layout()
            self.menuBar = wx.MenuBar( 0 )
            self.filemenu = wx.Menu()
            self.menuAbout = wx.MenuItem( self.filemenu, wx.ID_ANY, u"&About", u" Information about this program", wx.ITEM_NORMAL )
            self.filemenu.AppendItem( self.menuAbout )
    
            self.menuExit = wx.MenuItem( self.filemenu, wx.ID_ANY, u"E&xit", u" Terminate the program", wx.ITEM_NORMAL )
            self.filemenu.AppendItem( self.menuExit )
    
            self.menuBar.Append( self.filemenu, u"&miP3" )
    
            self.SetMenuBar( self.menuBar )
    
            self.statusBar = self.CreateStatusBar( 1, wx.ST_SIZEGRIP, wx.ID_ANY )
    
            self.Centre( wx.BOTH )
    
            self.Bind( wx.EVT_MENU, self.OnAbout, id = self.menuAbout.GetId() )
            self.Bind( wx.EVT_MENU, self.OnExit, id = self.menuExit.GetId() )
    
        def __del__( self ):
                pass
    
        def OnAbout( self, event ):
            event.Skip()
    
        def OnExit( self, event ):
            event.Skip()
    
    class ExamplePanel ( wx.Panel ):
    
        def __init__( self, parent ):
            wx.Panel.__init__ ( self, parent )
    
            # whatever you want on your panel goes here, for example a grid
            bSizer3 = wx.BoxSizer( wx.VERTICAL )
            self.m_grid1 = wx.grid.Grid( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
            self.m_grid1.CreateGrid( 5, 3 )
            self.m_grid1.EnableEditing( True )
            self.m_grid1.EnableGridLines( True )
            self.m_grid1.EnableDragGridSize( False )
            self.m_grid1.SetMargins( 0, 0 )
            self.m_grid1.EnableDragColMove( False )
            self.m_grid1.EnableDragColSize( True )
            self.m_grid1.SetColLabelSize( 30 )
            self.m_grid1.SetColLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
            self.m_grid1.EnableDragRowSize( True )
            self.m_grid1.SetRowLabelSize( 80 )
            self.m_grid1.SetRowLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
            self.m_grid1.SetDefaultCellAlignment( wx.ALIGN_LEFT, wx.ALIGN_TOP )
            bSizer3.Add( self.m_grid1, 1, wx.ALL|wx.EXPAND, 5 )
            self.SetSizer( bSizer3 )
            self.Layout()
    
        def __del__( self ):
            pass
    
    class MyFrame( ExampleFrame ):
        def __init__( self, parent ):
            ExampleFrame.__init__( self, parent )
    
            self.title = "Demo with Notebook"
            self.SetTitle(self.title)
    
            self.nb.AddPage(ExamplePanel(self.nb), "Absolute Positioning")
            self.nb.AddPage(ExamplePanel(self.nb), "Page Two")
            self.nb.AddPage(ExamplePanel(self.nb), "Page Three")
    
        def OnAbout(self, event):
            # A message dialoge box with an OK button. wx.OK is a sandard ID in wxWidgets
            dlg = wx.MessageDialog(self, "Author: Niek de Klein", "About miP3")
            dlg.ShowModal() # show it
            dlg.Destroy() # finally destroy it when finished
    
        def OnExit(self, eevent):
            self.Close(True) # close the frame
    
    class testapp(wx.App):
        def OnInit(self):
            self.m_frame = MyFrame(None)
            self.m_frame.Show()
            self.SetTopWindow(self.m_frame)
            return True
    
    app = testapp(0)
    app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.