'Push() function keeps disappearing whenever I change visibility of columns in Pysimplegui

Whenever I change the visibility of the columns within my layout, they become uncentered and move to the right. I'm currently using Push() to keep them centered but when a column's visibility changes, it's like it doesn't exist anymore. I've tried making all columns visible at once which had all three centered like I expected but once they become invisible and visible again they are off-center with no regard for any Push() functions. I'm not very good with python so if the answer is obvious, my apologies. Here's my code

import PySimpleGUI as sg

layout1 = [[sg.Text('Checkboxes')],
           *[[sg.CB(f'Checkbox {i}')] for i in range(5)]]

layout2 = [[sg.Text('Textboxes')],
           [sg.Input(key='-IN-')],
           [sg.Input(key='-IN2-')]]

layout3 = [[sg.Text('Radiobuttons')],
           *[[sg.R(f'Radio {i}', 1)] for i in range(5)]]

layout = [
    [sg.VPush()],
    [sg.Push(), sg.Column(layout1, key='-COL1-'), sg.Column(layout2, visible=False, key='-COL2-'), sg.Column(layout3, visible=False, key='-COL3-'), sg.Push()], #<-- This is the Push() function that stops working
    [sg.Push(), sg.Button('1'), sg.Button('2'), sg.Button('3'), sg.Button('Exit'), sg.Push()], 
    [sg.VPush()]
]

# Creation of window
window = sg.Window('Productivity Application', layout).finalize()
window.Maximize()

layouts = 1  # The currently visible layout

# Event list
while True:
    event, values = window.read()
    print(event, values)
    if event in (None, 'Exit'):
        break
    elif event in '123':
        window[f'-COL{layouts}-'].update(visible=False)
        layouts = int(event)
        window[f'-COL{layouts}-'].update(visible=True)

window.close()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source