Reputation: 113
I have created a GUI of a python code. I have created some elements in the window. I want the elements to be responsive to the window size. I have added a resizable=true property in the window object but it only makes the application window responsive not the elements contained within the window.
Code of Application
sg.theme('DefaultNoMoreNagging')
video_frame_column = [
[sg.Text("Scanner", justification="center")],
[sg.Image(filename="", key="-IMAGE-")]
]
functional_column = [
[sg.Text("Log Settings", justification="center")],
[
sg.Text("Scanned ID:", justification="center"),
sg.Text(size=(30, 1), key="-TOUT-", justification="center", background_color="white")
],
[sg.Button("Enter")],
[sg.Button("Exit")],
[sg.Button("Display Log")]
]
layout=[
[
sg.Column(video_frame_column),
sg.VSeperator(),
sg.Column(functional_column, element_justification='c')
]
]
window = sg.Window("Entry/Exit Log Management System", layout, location=(300, 150), resizable=True, finalize=True)
Image of the original size it has
Now if I click the maximize button the window appears as
Upvotes: 3
Views: 3817
Reputation: 13061
Set options expand_x=True
or/and expand_y=True
of element, maybe also same settings for its container if required.
import PySimpleGUI as sg
sg.theme('DefaultNoMoreNagging')
video_frame_column = [
[sg.Text("Scanner", justification="center")],
[sg.Image(filename='d:/images.png', background_color='green', expand_x=True, expand_y=True, key="-IMAGE-")]
]
functional_column = [
[sg.Text("Log Settings", justification="center")],
[
sg.Text("Scanned ID:", justification="center"),
sg.Text(size=(30, 1), key="-TOUT-", justification="center", background_color="white")
],
[sg.Button("Enter")],
[sg.Button("Exit")],
[sg.Button("Display Log")]
]
layout=[
[
sg.Column(video_frame_column, expand_x=True, expand_y=True),
sg.VSeperator(),
sg.Column(functional_column, element_justification='c')
]
]
window = sg.Window("Entry/Exit Log Management System", layout, location=(300, 150), resizable=True, finalize=True)
window.read(close=True)
Upvotes: 2