wxPython Layout Management-wxPython StaticBoxSizer - wxPython

What is the use of wxPython StaticBoxSizer?

A StaticBoxSizer puts a box sizer into a static box and it provides a border around the box along with a label at the top. Below steps are involved in preparing a statcboxsizer

  • Create a wx.StaticBox object.
  • Declare a wx.StaticBoxSizer with the above static box as its argument.
  • Create the controls and add in staticbox sizer.
  • Set it as the sizer for the frame.


In below example, two staticbox sizers are created and added into a top vertical box sizer, which controls the layout of the panel inside a frame.

First staticbox sizer is created around a static box named ‘Name’.

A Horizontal box sizer, holding two labels and two text boxes, is added into nmSizer static box sizer.

Similarly, another staticbox sizer holds a static box named ‘Buttons’.

Two button objects, named ‘ok’ and ‘cancel’ are put in a horizontal box sizer, which in turn, is placed inside the second staticbox sizer.

Two static box sizers, ‘name’ and ‘Buttons’ are added into a vertical box sizer acting as the layout manager of the panel in the top level frame.

Following is the complete code

The above code produces the following output


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

wxPython Topics