Web Analytics Made Easy - Statcounter
Skip to content

Multiple Columns

A Column is required when you have a tall element to the left of smaller elements.

In this example, there is a Listbox on the left that is 3 rows high. To the right of it are 3 single rows of text and input. These 3 rows are in a Column Element.

To make it easier to see the Column in the window, the Column background has been shaded blue. The code is wordier than normal due to the blue shading. Each element in the column needs to have the color set to match blue background.

cookbook columns

    import PySimpleGUI as sg      

    # Demo of how columns work      
    # GUI has on row 1 a vertical slider followed by a COLUMN with 7 rows    
    # Prior to the Column element, this layout was not possible      
    # Columns layouts look identical to GUI layouts, they are a list of lists of elements.    


    # Column layout      
    col = [[sg.Text('col Row 1', text_color='white', background_color='blue')],      
           [sg.Text('col Row 2', text_color='white', background_color='blue'), sg.Input('col input 1')],      
           [sg.Text('col Row 3', text_color='white', background_color='blue'), sg.Input('col input 2')]]      

    layout = [[sg.Listbox(values=('Listbox Item 1', 'Listbox Item 2', 'Listbox Item 3'), select_mode=sg.LISTBOX_SELECT_MODE_MULTIPLE, size=(20,3)), sg.Column(col, background_color='blue')],      
              [sg.Input('Last input')],      

    # Display the Window and get values    

    event, values = sg.Window('Compact 1-line Window with column', layout).Read()  

    sg.popup(event, values, line_width=200)