【发布时间】:2018-12-22 15:52:04
【问题描述】:
尝试运行以下程序时出现以下错误:
_tkinter.TclError: image "pyimage2" doesn't exist
当我使用TopLevel() 而不是tkinter.Tk() 时,出现了两个窗口,第二个窗口是主窗口。单击“登录按钮”后,再次出现相同(第二个)窗口
root = tkinter.Tk()
root.title("Facebook Analayzer")
main_font = ("URW Gothic L", 15, "bold")
main_font1 = ("URW Gothic L", 10, "bold")
font3 = ("Nimbus Mono L", 8, "bold")
root.maxsize(height=500, width=500)
root.minsize(height=500, width=500)
canvas = Canvas(root, width=256, height=256)
canvas.pack()
img = PhotoImage(file="fb.png")
canvas.create_image(20, 20, anchor=NW, image=img)
w = Label(root, text="Username", width=40)
w.config(font=main_font, fg="black")
w.pack()
e1 = Entry(root, width="30", bg="yellow")
e1.pack()
从评论中复制:登录按钮出现在代码的最后一行:
b1 = Button(root,
text="Login", bg="blue", fg="white", height="2", width="15",
command=start_prog
)
b1.config(font=main_font1)
b1.pack()
【问题讨论】:
-
我在你的代码中没有看到
Login Button...请分享你程序的所有相关部分。 -
登录按钮出现在代码的最后一行,即: b1 = Button(root, text="Login", bg="blue", fg="white", height="2", width="15", command=start_prog) b1.config(font=main_font1) b1.pack()
-
"_tkinter.TclError: image "pyimage2" doesn't exist": 阅读_tkinter.TclError: image “…” doesn't exist的答案
标签: python image tkinter toplevel