Python EasyGUI 如何在给定输入时保持 window 打开

Python EasyGUI How to keep window open when given input

我在 Python 并且正在使用 EasyGUI。我想知道如何在单击按钮后保持 easygui.buttonbox window 打开。

这是我的代码:

def Money():
    global budget #Not important
    run = 1
    while run == 1:
        money = easygui.buttonbox("$" + str(budget),
            choices = ['Money', 'Leave'])
        if money == "Money":
            budget = budget + 0.01
        if money == "Leave":
            run = 0

如果您知道如何做到这一点,请回答我将不胜感激。

谢谢!

EasyGUI 不是事件驱动的。这意味着它不会坐在那里等待事件发生,然后触发一些响应。所以按钮框只会在使用之前保持打开状态。它是同步的,阻塞的。

来自the documentation

EasyGUI is different from other GUI generators in that EasyGUI is NOT event-driven. Instead, all GUI interactions are invoked by simple function calls.

您可能还需要其他东西。