Reputation: 151
I am using PYsimpleGUI in my python code, and while using the popup element how do you resize the popup window?
My code:
import PySimpleGUI as sg
sg.popup("Hello!")
How to resize sg.popup?
Also, is there an option to add a title to the popup window?
Upvotes: 0
Views: 5861
Reputation: 1
You can use the popup scrolled to create a popup with size attributes:
example:
sg.popup_scrolled("Qty NOW: 12\nQty Initial: 11\nPN: CamposFields\nStatus: Start",
title="Running checks...",
auto_close=True,
auto_close_duration=10,
size=(30, 10)
)
Upvotes: 0
Reputation: 311
As already answered there is no size
parameter for the sg.popup()
function and you can use spaces and empty strings like paddings this way:
import PySimpleGUI as sg
# blanks like paddings example
sg.popup("", " Hello! \x00", "")
the empty strings before and after Hello! behave like vertical padding while the spaces inside Hello! string behave like horizontal padding.
Now you could ask why the hex escape character \x00
?
It's the workaround I found, stands for the Null character and without it doesn't pad on the right.
Upvotes: 0
Reputation: 56
Unfortunately there is no size parameter in sg.popup
, however you can adjust the size of the window by changing the contents of the text shown, ie. longer string and some empty lines.
Another option would be creating a new pop up funtion that works similar to the sg.popup
but based on sg.Window
object. This way you can be more flexible with the parameters.
You can add the title by using the title parameter: sg.popup('world', title='hello')
Upvotes: 3
Reputation: 7744
To resize while using the element, you can do that by using the Stretch element to push stuff around.
To set the title, it's simple as
import PySimpleGUI as sg
# Create the Window
window = sg.Window('Window Title', layout)
If you are new to the library, the documentation is a great place to start.
Upvotes: 0