Web Analytics Made Easy - Statcounter
Skip to content

Frame

Frame call reference

The Frame is another of the "Container Elements". It has an optional title and an optional border.

Frames work exactly the same way as Columns. You create layout that is then used to initialize the Frame. Like a Column element, it's a "Container Element" that holds one or more elements inside.

frame_layout2 = [[sg.Text('Py')],
                 [sg.Text('Simple')],
                 [sg.Text('GUI')]]

frame_layout1 = [[sg.Button('My Button!'), sg.Frame('Frame 2', frame_layout2, element_justification='center')]]

layout = [[sg.Frame('Frame 1', frame_layout1)]]

frame

Events

The Frame element does not produce any events.

Values Dictionary

There is no Values Dictionary entry for the Frame element.

No Title, No Border == Column

They are very similar to Column elements with 2 main differences:

  1. Frame may have a Title
  2. Frames may have a border

Both of these are optional items. If the title is set to an empty string "" and the border_width is set to 0, then the result is identical to a Column element.

In this example, the row with the Column and the Frame have identically sized red colored areas.

layout1 = [[sg.Button('Button'), sg.Checkbox('Checkbox')]]
layout2 = [[sg.Button('Button'), sg.Checkbox('Checkbox')]]
layout3 = [[sg.Button('Button'), sg.Checkbox('Checkbox')]]

layout = [[sg.Frame('Frame', layout1, background_color='red')],
          [sg.Column(layout2, background_color='red'), sg.Frame('', layout3, border_width=0, background_color='red')]]

image