【发布时间】:2018-03-26 03:04:18
【问题描述】:
我目前正在尝试创建一个 Python3 Tkinter 程序,我可以通过双击或从其他 python 脚本打开来启动它,而不是通过空闲。
到目前为止,我运气不佳,因为当我尝试启动脚本时,控制台会打开一会儿然后崩溃。
编辑:删除标志代码段允许程序运行。任何想法为什么以及如何解决它?另外,在控制台运气不佳之前,我不必通过控制台运行程序。
from tkinter import *
from tkinter import ttk
root = Tk()
root.title("Kinematics")
Logo_frame = LabelFrame(root, bg = "white")
Logo_frame.grid(row=0, column=12, sticky = "NSEW")
#Logo
Logo = Image(file="Logo-S.gif")
image_label = ttk.Label(Logo_frame, image=Logo)
image_label.grid(row=0, column=0, rowspan = 3)
root.mainloop()
【问题讨论】:
-
针对“控制台打开片刻然后崩溃”问题的一般调试技术:从控制台运行程序,这样您就可以看到错误消息的实际内容。
-
请不要发布工作代码。发布导致错误的代码,然后在您的问题中包含错误。
-
我试图在不使用 IDLE 的情况下启动它,但当我尝试它不起作用时。那里的代码,特别是#Logo 部分似乎破坏了它。
标签: python python-3.x tkinter