PySimpleGUI App Layouts Not Resizing Properly When Changing Layouts on the Same Window”?

My app has different layouts that update visibily to hide and unhide the layouts. Hiding these layouts and showing a different one is done through event calls(button clicks). The problem is that when these layouts are changed, the window doesn’t adjust itself to match the elements of the new layout. For example layout one has 3 input elements and 2 buttons but layout two has a table element, when switching to display layout two the table is smaller than the window.

Code:

import PySimpleGUI as sg
from database import *

sg.set_options(font=("Courier", 12))

#get all added records from database
records = getRecords()
print(records)

#check if inputs are empty
def checkMissingInput(lst):
    for i in lst:
        if i == '':
            return True
    return False

#create window to add records
def main():
    #root/main layout
    addRecordsLayout = [
        [sg.Push(), sg.Text("Password Manager"), sg.Push()],
        [sg.Text("URL "), sg.Push(), sg.Input("www.apple.com",enable_events=True, key="input-url")],
        [sg.Text("Username/Email "), sg.Push(), sg.Input("[email protected]",enable_events=True, key="input-username")],
        [sg.Text("Password "), sg.Push(), sg.Input("john123",enable_events=True, key="input-password")],

        [sg.Button("Add Record", enable_events=True, key="add-records", expand_x=True), 
         sg.Button("Show Records", enable_events=True, key="show-records", expand_x=True), 
         sg.Button("Clear", enable_events=True, key="clear", expand_x=True)]
    ]

    #second layout, for viewing table of records
    toprows = ["Id","Url","Username","Password"]
    showRecordsLayout = [
        [sg.Push(),sg.Text("Records"),sg.Push()],
        [sg.Push(),sg.Table(key='records-table',values=records, headings=toprows, 
                  expand_x=True,
                  expand_y=True,
                  justification="center",
                  auto_size_columns=True,
                  enable_click_events=True 
                  ),sg.Push()],
        [sg.Button("Select",key="select-records",expand_x=True,enable_events=True),
         sg.Button("Exit",key="exit-show-records",expand_x=True,enable_events=True)]
    ]

    #third layout, for viewing selected layout from table
    showSelectedRecordLayout = [
        #[sg.Text(f"Record {selectRecordId}")]
        [sg.Text("Url: ")],
        [sg.Text("Username: ")],
        [sg.Text("Password: ")],

        [sg.Button("Delete", expand_x=True, key="delete-record-button"),
         sg.Button("Return", expand_x=True, key="exit-selected-record")]
    ]

    rootLayout = [[sg.Column(addRecordsLayout, key="column-1", visible=True)],
                  [sg.Column(showRecordsLayout, key="column-2", visible=False)],
                  [sg.Column(showSelectedRecordLayout, key="column-3", visible=False)]]

    window = sg.Window("Password Manager", rootLayout)
    while True:
        event, values = window.read()
    
        #events
        if event == sg.WIN_CLOSED:
            print(event)
        
            break
        elif event == 'clear':
            window['input-url'].update('')
            window['input-username'].update('')
            window['input-password'].update('')

        elif event == 'add-records':
            inputElementValues = list(values.values()) #get list all values in input elements
            try:
                if checkMissingInput(inputElementValues) == True:
                    sg.popup("Missing input values...")
                else:
                    addDbRecord(inputElementValues[0], inputElementValues[1], inputElementValues[2]) #add list of input values to database table
                    sg.popup("Record succesfully added...")

            except ValueError:
                print("ValueError")
        
        elif event == 'show-records':
            window["column-1"].update(visible=False)
            window["column-2"].update(visible=True)
            window['records-table'].update(values=getRecords()) #update records table to display new added records based on whats in database table

        if event == 'exit-show-records':
            window["column-1"].update(visible=True)
            window["column-2"].update(visible=False)

        elif event == 'select-records':
            window["column-2"].update(visible=False)
            window["column-3"].update(visible=True)
            print(values['records-table'])
        
        elif event == 'exit-selected-record':
            window["column-2"].update(visible=True)
            window["column-3"].update(visible=False)
    window.close()

if __name__ == "__main__":
    main()

I’ve tried updating the window size with every event, but nothing has worked so far. Any help would be gladly appreciated!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật