【发布时间】:2018-09-27 03:07:24
【问题描述】:
每当我尝试在 ubuntu 16.04.2 上使用 tk.mainloop() 运行简单的 tkinter 程序或任何适用于该母校的程序时,我都无法打开应用程序窗口,并且窗口图标上会显示一个问号。
这是我正在运行的程序:
import tkinter as tk
class MainApplication(tk.Frame):
def __init__(self, parent, *args, **kwargs):
super(MainApplication, self).__init__(parent, *args, **kwargs)
if __name__ == '__main__':
root = tk.Tk()
MainApplication(root).pack(side="top", fill="both", expand=True)
root.mainloop()
下面是我运行程序时显示程序输出的屏幕截图:
在此之前,我收到一条错误消息,提示 _tkinter 可以加载。为了解决这个问题,我使用sudo apt-get update 然后sudo apt-get install python3-tk 为ubuntu 下载了最新版本的tkinter。如果这也很重要,我在 Windows 10 的双启动配置中使用 ubuntu。
我也读过How can I fix program icons that appear as a question mark in the Launcher? 和Why do some open applications appear as “question marks” in the Unity launcher?,但这些问题似乎是关于如何修复应用程序桌面图标,而不是如何修复无法运行的应用程序。此外,问题似乎与特定的 ubuntu 应用程序有关。
有谁知道为什么 ubuntu 不能正确运行 tkinter 应用程序以及可以做些什么来解决这个问题?
【问题讨论】:
标签: python python-3.x ubuntu tkinter ubuntu-16.04