结合 Tkinter 和 win32ui 使 Python 在退出时崩溃 [英] Combining Tkinter and win32ui makes Python crash on exit

查看:50
本文介绍了结合 Tkinter 和 win32ui 使 Python 在退出时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用带有 Python 2.7 的 winapi 构建基本应用程序时(我使用的是 Windows 8.1),我尝试向该程序添加一个小的 Tkinter gui.问题是,每当我关闭应用程序窗口时,Python 就会完全崩溃(基本上是获取崩溃消息).

While building a basic app using the winapi with Python 2.7 (I'm on Windows 8.1), I tried to add a small Tkinter gui to the program. The problem is, whenever I close the app window, Python crashes completely (getting crash messages basically).

我在多个地方发现了有关此问题的报告,但找不到修复程序或解决方案.以下是一些来源:

I have found reports of this issue in several places, but couldn't find a fix or solution. Here are some sources:

http://sourceforge.net/p/pywin32/bugs/443/#8bde

http://www.gossamer-threads.com/lists/python/python/134956(这个是 2002 年的!)

http://www.gossamer-threads.com/lists/python/python/134956 (this one is from 2002!)

最多可以用这 4 行来复制:

It can be reproduced with as much as these 4 lines:

from Tkinter import Tk
import win32ui

root = Tk()
root.mainloop()

并在运行后关闭窗口.有谁知道解决方案?有什么解决方法的建议吗?

And closing the window after running it. Does anyone know of a solution for this? Any recommendations for a workaround maybe?

推荐答案

一种解决方法是使用 pythonw 调用 Tkinter-win32UI 应用.Python 不会崩溃.

A workaround is to invoke the Tkinter-win32UI app with pythonw. Python doesn't crash.

在 Win 10 上使用 Python 3.6.3 测试.

Tested with Python 3.6.3 on Win 10.

这篇关于结合 Tkinter 和 win32ui 使 Python 在退出时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆