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 8231369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:27:52+00:00 2026-06-07T17:27:52+00:00

I’m a newbie in wxpython and have been trying to put some widgets within

  • 0

I’m a newbie in wxpython and have been trying to put some widgets within books(treebook, notebook, choicebook) I have often ended up with some widgets placed inside containers not responding to events. I’m not sure what I’m doing wrong. Below is one of my code

import wx

class ChoicePanelTwo(wx.Panel):
    def __init__(self, parent, seed):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
        self.SetBackgroundColour('blue')
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.List = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
        for i in range(seed):
            self.List.InsertStringItem(i, str(i))
        sizer.Add(self.List, 1, wx.ALL|wx.EXPAND, 5)
        self.SetSizer(sizer)

class ChoicePanelOne(wx.Panel):
    def __init__(self, parent, seed):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
        self.SetBackgroundColour('green')
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.RegisterList = wx.Choicebook(self, wx.ID_ANY)
        sizer.Add(self.RegisterList, 1, wx.ALL|wx.EXPAND, 5)
        for i in range(seed):
            self.RegisterList.AddPage(ChoicePanelTwo(self, seed*50),  str(i))
        self.SetSizer(sizer)

class TreePanel(wx.Panel):
    def __init__(self, parent, seed):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY)
        self.SetBackgroundColour('cyan')
        self.Choicbook = wx.Choicebook(self, wx.ID_ANY)
        for i in range(seed):
            self.Choicbook.AddPage(ChoicePanelOne(self, seed*2), str(i))
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.Choicbook, 1, wx.ALL|wx.EXPAND, 5)
        self.SetSizer(sizer)

class AppFrame(wx.Frame):
    """ The main frame of the application
    """
    title = 'Application'
    WindowSize = (1024, 768)
    seed = 2

    def __init__(self):
        wx.Frame.__init__(self, None, -1, self.title, size=self.WindowSize, style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)
        self.create_main_panel()

    def create_main_panel(self):
        self.panel = TreePanel(self, self.seed)        

if __name__ == '__main__':
    app = wx.PySimpleApp()
    app.frame = AppFrame()
    app.frame.Show()
    app.MainLoop()

In this example. The choice book and list does seem to be working. What is that I’m doing wrong ?

  • 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-07T17:27:54+00:00Added an answer on June 7, 2026 at 5:27 pm

    It’s a parenting issue. You are setting all the ChoicePanelOne instance’s parents as the TreePanel when it should be the ChoicBook. And you’re doing the same thing in ChoicePanelOne where you create a whole bunch of ChoicePanelTwo’s whose parents are ChoicePanelOne when they should be RegisterList. Check out the slightly changed code below:

    import wx
    
    class ChoicePanelTwo(wx.Panel):
        def __init__(self, parent, seed):
            wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
            self.SetBackgroundColour('blue')
            sizer = wx.BoxSizer(wx.HORIZONTAL)
            self.List = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
            for i in range(seed):
                self.List.InsertStringItem(i, str(i))
            sizer.Add(self.List, 1, wx.ALL|wx.EXPAND, 5)
            self.SetSizer(sizer)
    
    class ChoicePanelOne(wx.Panel):
        def __init__(self, parent, seed):
            wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
            self.SetBackgroundColour('green')
            sizer = wx.BoxSizer(wx.HORIZONTAL)
            self.RegisterList = wx.Choicebook(self, wx.ID_ANY)
            sizer.Add(self.RegisterList, 1, wx.ALL|wx.EXPAND, 5)
            for i in range(seed):
                self.RegisterList.AddPage(ChoicePanelTwo(self.RegisterList, seed*50),  str(i))
            self.SetSizer(sizer)
    
    class TreePanel(wx.Panel):
        def __init__(self, parent, seed):
            wx.Panel.__init__(self, parent, id=wx.ID_ANY)
            self.SetBackgroundColour('cyan')
            self.Choicbook = wx.Choicebook(self, wx.ID_ANY)
            for i in range(seed):
                self.Choicbook.AddPage(ChoicePanelOne(self.Choicbook, seed*2), str(i))
            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self.Choicbook, 1, wx.ALL|wx.EXPAND, 5)
            self.SetSizer(sizer)
    
    class AppFrame(wx.Frame):
        """ The main frame of the application
        """
        title = 'Application'
        WindowSize = (1024, 768)
        seed = 2
    
        def __init__(self):
            wx.Frame.__init__(self, None, -1, self.title, size=self.WindowSize, 
                              style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN)
            self.create_main_panel()
    
        def create_main_panel(self):
            self.panel = TreePanel(self, self.seed)        
    
    if __name__ == '__main__':
        app = wx.PySimpleApp()
        app.frame = AppFrame()
        app.frame.Show()
        app.MainLoop()
    

    You should download the wxPython demo as it has lots of good examples in it. Also see the wiki or my blog article.

    You could use the Widget Inspection Tool to help you diagnose the problem as well as it will show you what parent is where and how your sizers are laid out, among other things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
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 am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.