【发布时间】:2020-08-11 09:36:50
【问题描述】:
我对编码很陌生,我正在尝试在 tkinter 窗口中显示图像。
但是,当我运行下面的代码时,图像应该在的位置存在间隙。我也没有从这段代码中得到任何错误。
window2 = Toplevel()
window2.geometry("1920x1200")
Namearea = Label(window2, text="Please Name the Prebuild:")
Namearea.pack()
e = Entry(window2, width=50, borderwidth=3, bg="Light Grey", fg="black")
e.pack()
#Here is the part that is not working.
img3 = PhotoImage(file=r"C:\\Tkinter\\ComputerImage.png")
picture1 = Label(window2, image=img3)
picture1.pack()
SaveAndContinue = Button(window2, text="Save and Return to Main Menu", padx=75, pady=20, bg="Light Grey")
SaveAndContinue.pack()
【问题讨论】:
-
这段代码在函数内部吗?
-
是的,它在函数内部