Tkinter 窗口与 Pygame 窗口一起打开

问题描述 投票:0回答:1

我正在编写一些Python代码,最初会打开一个TKinter窗口,当它关闭时,它应该并且确实会打开一个Pygame窗口。您可以提示在 Pygame 窗口旁边打开另一个 TKinter 窗口。

当第二个 Tkinter 窗口打开时,Pygame 窗口不会按预期“暂停”。

threading.Thread(target=settings_).start()
    #the above fixes the crashes but I need the Pygame window to pause hence below code
    #settings_()
    is_open = "yes"
    while is_open == "yes":
        f = open("is_settings_open.txt", "r")
        is_open = str((f.read()))
        pygame.time.delay(10)
        # causes same issue
python linux tkinter pygame
1个回答
0
投票

回答我自己:

对于 Pygame 窗口基本上无响应的预期结果,包括在 tkinter 窗口打开时无法关闭它,我没有使用 pygame.time.display/wait 或 time.sleep,因为所有这些都会导致崩溃。相反,我将

and is_open == "no"
添加到所有功能检查中(检查是否按下按钮)。我还在此处添加了它,以防止窗口关闭:

for event in pygame.event.get():
    if (event.type == pygame.QUIT  and is_open == "no"):
        running = False
© www.soinside.com 2019 - 2024. All rights reserved.