简体   繁体   English

如何在python的PysimpleGUI中更改弹出大小?

[英]How to change the popup size in PysimpleGUI in python?

I am using PYsimpleGUI in my python code, and while using the popup element how do you resize the popup window?我在我的 python 代码中使用 PYsimpleGUI,在使用 popup 元素时如何调整弹出窗口的大小?

My code:我的代码:

import PySimpleGUI as sg
sg.popup("Hello!")

How to resize sg.popup?如何调整 sg.popup 的大小?

Also, is there an option to add a title to the popup window?另外,是否可以选择向弹出窗口添加标题?

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.不幸的是sg.popup没有 size 参数,但是您可以通过更改显示的文本内容来调整窗口的大小,即。 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.另一种选择是创建一个新的弹出功能,它的工作原理类似于sg.popup但基于sg.Window对象。 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')您可以使用 title 参数添加标题: sg.popup('world', title='hello')

To resize while using the element, you can do that by using the Stretch element to push stuff around.要在使用元素时调整大小,您可以通过使用 Stretch 元素来推动东西。

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.如果您是图书馆的新手,那么文档是一个很好的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM