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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:56:32+00:00 2026-06-16T07:56:32+00:00

Started learning wxPython so I could make an application. I’m having issues with nested

  • 0

Started learning wxPython so I could make an application. I’m having issues with nested sizers in particular.

class browser_mainPanel(wx.Panel):

   def __init__(self, parent):
     wx.Panel.__init__(self, parent=parent)
     self.toolbar()
     self.searchBar = wx.SearchCtrl(self)

     main_sizer = wx.BoxSizer(wx.HORIZONTAL)

     main_sizer2 = wx.BoxSizer(wx.VERTICAL)   
     main_sizer2.Add(self.toolBar, 0, wx.EXPAND, 5)   
     main_sizer2.Add(self.searchBar, 0, wx.EXPAND, 5)

     main_sizer.Add(main_sizer2, wx.EXPAND)

     tree_panel = wx.Panel(self)
     tree_panel.SetBackgroundColour(wx.BLACK)
     entry_panel = wx.Panel(self)
     entry_panel.SetBackgroundColour(wx.GREEN)

     main_sizer3 = wx.BoxSizer(wx.HORIZONTAL)
     main_sizer3.Add(tree_panel, 0, wx.EXPAND, 5)
     main_sizer3.Add(entry_panel, 0, wx.EXPAND, 5)
     main_sizer2.Add(main_sizer3, wx.EXPAND)
     self.SetSizer(main_sizer)

Right, so the problem is that the two panels in main_sizer3 aren’t expanding out as I want them to. Here’s a picture.

What I want is for the two panels to expand to the rest of the panel with the black portion
being smaller than the green panel width-wise. Can’t find a solution for the life of me.

I plan on making these two panels have their own special instances because there’s going to be stuff happening in them but for now, I’m looking to implement them as simply as possible before I start getting into the details.

  • 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-16T07:56:34+00:00Added an answer on June 16, 2026 at 7:56 am

    You forgot a few proportions:

    # to use the last parameter (border), you have to
    # specify which border(s) to use in the flag parameter:
    # wx.TOP, wx.BOTTOM, wx.LEFT, wx.RIGHT, a combination
    # of them, or wx.ALL
    main_sizer2.Add(self.toolBar, 0, wx.EXPAND|wx.BOTTOM, 5)
    main_sizer2.Add(self.searchBar, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
    # proportion missing:
    main_sizer.Add(main_sizer2, 1, wx.EXPAND)
    
    # set the green panel to twice the size of the black one
    main_sizer3.Add(tree_panel, 1, wx.EXPAND|wx.RIGHT, 5)
    main_sizer3.Add(entry_panel, 2, wx.EXPAND)
    # and another proportion missing:
    main_sizer2.Add(main_sizer3, 1, wx.EXPAND|wx.ALL, 5)
    

    Furthermore, your main_sizer only contains one entry which makes it superfluous. Also try to give your sizers somewhat meaningful names to make it easier to read.

    Last but not least, if you want the user to be able to dynamically resize the proportions of the two panels (tree and entry), you
    can use a wx.SplitterWindow:

    # ...
    layout = wx.BoxSizer(wx.VERTICAL)
    layout.Add(self.toolBar, 0, wx.EXPAND|wx.BOTTOM, 5)
    layout.Add(self.searchBar, 0, wx.EXPAND|wx.LEFT|wx.RIGHT,5)
    
    splitter = wx.SplitterWindow(self,style=wx.SP_LIVE_UPDATE)
    
    tree_panel = wx.Panel(splitter)
    tree_panel.SetBackgroundColour(wx.BLACK)
    entry_panel = wx.Panel(splitter)
    entry_panel.SetBackgroundColour(wx.GREEN)
    
    splitter.SplitVertically(tree_panel,entry_panel)
    splitter.SetMinimumPaneSize(50)
    
    layout.Add(splitter,1,wx.EXPAND|wx.ALL,5)
    self.SetSizer(layout)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm learning wxPython and am converting an application I wrote in python +
I started learning how to make a module in perl with perltoot : package
I've recently started learning python and am having some trouble. The functions in question
I started learning C++, classes, objects, structures and more, but I'm having some problems
Recently started learning ruby and I've created a class for family members that contains
I started learning hash tables, so could anybody explain how the programm works. Although,
Started learning javascript yesterday at CodeAcademy and decided I could actually write code. Just
I started learning Django recently and am having a strange problem with the tutorial.
I started learning oop php and I don't understand how to make a method
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python

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.