Reputation: 7541
How do I enable the maximize button, and how do I react to it?
I think the way to react to it is to use the maximize()
and normal()
functions on the window object, like so:
import PySimpleGUI as sg
layout = [[sg.Button('Save')]]
window = sg.Window('Window Title', layout,
default_element_size=(12, 1))
while True:
event, values = window.read()
if event == 'Save':
print('clicked save')
if event == sg.WIN_MAXIMIZED: # I just made this up, and it does not work. :)
window.maximize()
if event == sg.WIN_CLOSED:
break
The Maximize button is not enabled in the window bar, so I can't click it and try to find the event, I feel like there is something I need to do to tell the window that there is a callback for maximizing the window.
I have a similar question to this question, but not using TK and instead with PySimpleGUI.
Upvotes: 1
Views: 1887
Reputation: 7541
To enable the window to be resizable, you just need to add resizable
to the window declaration.
import PySimpleGUI as sg
layout = [[sg.Button('Save')]]
window = sg.Window('Window Title',
layout,
default_element_size=(12, 1),
resizable=True) # this is the change
while True:
event, values = window.read()
if event == 'Save':
print('clicked save')
if event == sg.WIN_MAXIMIZED: # I just made this up, and it does not work. :)
window.maximize()
if event == sg.WIN_CLOSED:
break
I found the solution!
Upvotes: 4