How to change the popup size in PysimpleGUI in python?
Question:
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?
Answers:
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.
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')
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.
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?
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.
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')
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.