topper = Toplevel()
topper.title("2nd Window")
topper.state('zoomed')
my_img = ImageTk.PhotoImage(Image.open("diamond.png"))
my_label = Label(topper, image=my_img, height = 100 , width = 100)
F21 = Frame(topper, borderwidth=83, bg="blue", relief=SUNKEN)
button1 = Button(topper, text="class", command=topper.destroy)
button1.pack()
my_label.pack()
我正在运行代码,我没有得到错误,按钮是工作以及,但我不能看到窗口中的图片。
1条答案
按热度按时间9q78igpj1#
欢迎来到我们的网站!
对于将来-提供Minimal, Reproducible Example总是好的,这样其他人就可以复制和更好地理解您的问题,以便帮助您!它还可以帮助您了解错误的确切来源。
当你从另一个tkinter窗口调用Toplevel()来打开一个新窗口时,你还需要在第二个窗口调用“mainloop()”来显示一个图像--试试我的代码中的一个示例图像,并使用注解/取消注解该行
以查看功能上的差异。
修改后的代码: