如何在PYsimpleGUI中调整sg.window大小?

7

我将在我的 Python 代码中使用 PYsimpleGUI,而在使用窗口元素创建主窗口时,这是我的代码:

我的代码:

import PySimpleGUI as sg

layout = [ [sg.Button('Close')] ]

window = sg.Window('This is a long heading.', layout)
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Close':
        break
    break
window.close()

我发现当我运行这个程序时,在窗口自动调整大小并变得较小的情况下,完整标题没有显示。

是否有一种方法可以调整sg.window的大小?

1个回答

7

你可以在 sg.Window 中添加尺寸参数。

尝试一下:

import PySimpleGUI as sg

layout = [ [sg.Button('Close')] ]

window = sg.Window('This is a long heading.', layout,size=(290, 50))
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Close':
        break
    break
window.close()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接