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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:07:24+00:00 2026-05-28T18:07:24+00:00

I have made a GUI where there are 4 main tabs, the 4 tabs

  • 0

I have made a GUI where there are 4 main tabs, the 4 tabs are then split in half, with another notebook on the left and an empty panel on the right (a graph will go here). See image for below of my GUI.enter image description here

The problem I am having is that I cannot resize the notebook on the left to fit the contents of the notebook. By fitting its contents I mean I want the right hand side of the notebook to be pulled in. I also want the size to remain fixed so If I resized the window by clicking and dragging the right hand corner it wont resize the notebook, but the panel on the right will get bigger/smaller depending on whether the user clicked and dragged.

Code below:

import wx
import wx.grid

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

        self.notebook_2 = wx.Notebook(self, -1, style=0)
        self.notebook_2_pane_1 = wx.Panel(self.notebook_2, -1)
        self.notebook_2_pane_2 = wx.Panel(self.notebook_2, -1)
        self.notebook_2_pane_3 = wx.Panel(self.notebook_2, -1)
        self.notebook_2_pane_4 = wx.Panel(self.notebook_2, -1)
        self.notebook_3 = wx.Notebook(self.notebook_2_pane_1, -1, style=0)
        self.notebook_3a = wx.Notebook(self.notebook_3, -1, style=0)
        self.notebook_4 = wx.Notebook(self.notebook_3, -1, style=0)
        self.panel_2a = wx.Panel(self.notebook_4, -1)
        self.panel_2b = wx.Panel(self.notebook_3a, -1)
        self.panel_2c = wx.Panel(self.notebook_3a, -1)
        self.panel_2 = wx.Panel(self.notebook_3, -1)
        self.panel_1 = wx.Panel(self.notebook_2_pane_1, -1)
        self.grid_1 = wx.grid.Grid(self.panel_2a, -1, size=(1, 1))
        self.grid_2 = wx.grid.Grid(self.notebook_4, -1, size=(1, 1))
        self.bws_btn = wx.Button(self.panel_2b, -1, "Browse...")
        self.tctrl = wx.TextCtrl(self.panel_2b, -1) 
        self.filename = wx.StaticText(self.panel_2b, -1, 'File:')
        self.limitdata = wx.StaticText(self.panel_2b, -1, 'Limit Data:')
        self.tctrl3 = wx.TextCtrl(self.panel_2b, -1, '200') 
        self.disp_sel_pk = wx.StaticText(self.panel_2c, -1, 'Display Selected Data')
        self.toggle = wx.ToggleButton(self.panel_2c, 1, 'Toggle')
        self.add_peak = wx.StaticText(self.panel_2c, -1, 'Add Data:')
        self.add_peak_tctrl = wx.TextCtrl(self.panel_2c, -1, 'Test') 
        self.add_peak_btn = wx.Button(self.panel_2c, -1, "Add")
        self.capt_click = wx.Button(self.panel_2c, -1, "Capture Mouse Click")   
        self.save_btn = wx.Button(self.panel_2a, -1, "Save as CSV file")
        self.update_btn = wx.Button(self.panel_2a, -1, "Update")

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

    def __set_properties(self):
        # begin wxGlade: MyFrame1.__set_properties
        self.SetTitle("frame_2")
        self.SetMinSize((800, 600))

        self.grid_1.CreateGrid(30, 3)
        self.grid_1.SetRowLabelSize(0) # hide the rows
        self.grid_1.SetColLabelValue(0, "Data ID")
        self.grid_1.SetColLabelValue(1, "Test")
        self.grid_1.SetColLabelValue(2, "Frquency")

        self.grid_2.CreateGrid(30, 13)
        self.grid_2.SetRowLabelSize(30)
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame1.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.VERTICAL)
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5.Add(self.filename, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_4.Add(self.bws_btn, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_4.Add(self.tctrl, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_6.Add(self.limitdata, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_6.Add(self.tctrl3, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_1.Add(sizer_5)
        sizer_1.Add(sizer_4)
        sizer_1.Add(sizer_6)


        sizer_1a = wx.BoxSizer(wx.VERTICAL)
        sizer_1a.Add(self.grid_1, 1, wx.EXPAND, 0)
        sizer_1a.Add(self.save_btn, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_1a.Add(self.update_btn, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        self.panel_2b.SetSizer(sizer_1)
        self.panel_2a.SetSizer(sizer_1a)

        sizer_1b = wx.BoxSizer(wx.VERTICAL)
        sizer_4a = wx.BoxSizer(wx.HORIZONTAL)
        sizer_5a = wx.BoxSizer(wx.HORIZONTAL)
        sizer_6a = wx.BoxSizer(wx.HORIZONTAL)
        sizer_7a = wx.BoxSizer(wx.HORIZONTAL)
        sizer_8a = wx.BoxSizer(wx.HORIZONTAL)
        sizer_4a.Add(self.disp_sel_pk, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_5a.Add(self.toggle, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)
        sizer_6a.Add(self.add_peak, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)        
        sizer_7a.Add(self.add_peak_tctrl, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)      
        sizer_7a.Add(self.add_peak_btn, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)  
        sizer_8a.Add(self.capt_click, flag=wx.EXPAND | wx.RIGHT | wx.Left | wx.TOP | wx.BOTTOM, border=10)   
        sizer_1b.Add(sizer_4a)
        sizer_1b.Add(sizer_5a)
        sizer_1b.Add(sizer_6a)
        sizer_1b.Add(sizer_7a)
        sizer_1b.Add(sizer_8a)
        self.panel_2c.SetSizer(sizer_1b)

        self.notebook_3.AddPage(self.notebook_3a, "Inputs")
        self.notebook_3.AddPage(self.notebook_4, "Results")
        self.notebook_3a.AddPage(self.panel_2b, "Graph")
        self.notebook_3a.AddPage(self.panel_2c, "Calc")
        self.notebook_4.AddPage(self.panel_2a, "Info")
        self.notebook_4.AddPage(self.grid_2, "Info2")
        sizer_3.Add(self.notebook_3, 1, wx.EXPAND, 0)
        sizer_3.Add(self.panel_1, 1, wx.EXPAND, 0)

        self.notebook_2_pane_1.SetSizer(sizer_3)
        self.notebook_2.AddPage(self.notebook_2_pane_1, "Setup")
        self.notebook_2.AddPage(self.notebook_2_pane_2, "Optimisation")
        self.notebook_2.AddPage(self.notebook_2_pane_3, "Algorithm")
        self.notebook_2.AddPage(self.notebook_2_pane_4, "Data")
        sizer_2.Add(self.notebook_2, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_2)
        sizer_2.Fit(self)
        self.Layout()

if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_2 = MyFrame1(None, -1, "")
    app.SetTopWindow(frame_2)
    frame_2.Show()
    app.MainLoop()
  • 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-05-28T18:07:25+00:00Added an answer on May 28, 2026 at 6:07 pm

    Check this code to see how proportions are given to widgets when added to container sizers in order to produce what you want.
    You must set the panel proportion to 1 (occupy 100% of all space available for the widget) and the notebook proportion to 0 (occupy the minimal space needed to hold its child widgets):

    #!/usr/bin/env python
    # -*- coding: iso-8859-15 -*-
    # generated by wxGlade HG on Sat Jan 21 15:09:27 2012
    
    import wx
    
    # begin wxGlade: extracode
    # end wxGlade
    
    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)
            self.notebook_1 = wx.Notebook(self, -1, style=0)
            self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1)
            self.notebook_2 = wx.Notebook(self.notebook_1_pane_1, -1, style=0)
            self.notebook_2_pane_1 = wx.Panel(self.notebook_2, -1)
            self.button_1 = wx.Button(self.notebook_2_pane_1, -1, "button_1")
            self.notebook_2_pane_2 = wx.Panel(self.notebook_2, -1)
            self.panel_1 = wx.Panel(self.notebook_1_pane_1, -1)
            self.notebook_1_pane_2 = wx.Panel(self.notebook_1, -1)
            self.notebook_1_pane_3 = wx.Panel(self.notebook_1, -1)
    
            self.__set_properties()
            self.__do_layout()
            # end wxGlade
    
        def __set_properties(self):
            # begin wxGlade: MyFrame.__set_properties
            self.SetTitle("frame_1")
            self.panel_1.SetBackgroundColour(wx.Colour(255, 255, 0))
            # end wxGlade
    
        def __do_layout(self):
            # begin wxGlade: MyFrame.__do_layout
            sizer_1 = wx.BoxSizer(wx.VERTICAL)
            sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
            sizer_3 = wx.BoxSizer(wx.VERTICAL)
            sizer_3.Add(self.button_1, 0, 0, 0)
            self.notebook_2_pane_1.SetSizer(sizer_3)
            self.notebook_2.AddPage(self.notebook_2_pane_1, "tab1")
            self.notebook_2.AddPage(self.notebook_2_pane_2, "tab2")
    
            sizer_2.Add(self.notebook_2, 0, wx.EXPAND, 0)      #<- notebook,proportion 0
            sizer_2.Add(self.panel_1, 1, wx.EXPAND, 0)         #<- panel,   proportion 1
    
            self.notebook_1_pane_1.SetSizer(sizer_2)
            self.notebook_1.AddPage(self.notebook_1_pane_1, "tab1")
            self.notebook_1.AddPage(self.notebook_1_pane_2, "tab2")
            self.notebook_1.AddPage(self.notebook_1_pane_3, "tab3")
            sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)
            self.SetSizer(sizer_1)
            sizer_1.Fit(self)
            self.Layout()
            # end wxGlade
    
    # end of class MyFrame
    
    
    if __name__ == "__main__":
        app = wx.PySimpleApp(0)
        wx.InitAllImageHandlers()
        frame_1 = MyFrame(None, -1, "")
        app.SetTopWindow(frame_1)
        frame_1.Show()
        app.MainLoop()
    

    enter image description here

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

Sidebar

Related Questions

I have made a java swing GUI. Now I want to display a static
I have just made my first proper little desktop GUI application that basically wraps
I have GUI in Matlab that I have made using the Programmatic approach. It
I have made a java program with GUI and I want a stop button
I have made accelerators in my java gui by using setAccelerator(), and they work
I currently have the GUI made for a simon says game, the only problem
I have made a SVG image, or more like mini application, for viewing graphs
I have made some code which exports some details of a journal article to
I have made a custom UserControl i Vb.net (windows application). How can I add
I have made a little app for signing up for an event. User input

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.