【发布时间】:2019-10-16 11:55:56
【问题描述】:
我正在尝试将图像添加到屏幕但它不显示。
遵循其他堆栈溢出解决方案和 Effbot 解决方案,但均未奏效。我已经移动了图像,但它仍然没有显示,所以它不在显示的位置。也没有收到任何错误消息。
image = PhotoImage("newspaper-extra-computer-icons-breaking-newsnewspaper.jpg")
image_label = Label(news_aggregator,image = image)
image_label.image = image
image_label.place(x=400,y = 200)
只是希望显示图像。
【问题讨论】:
-
两件事:第一,您必须将文件名作为关键字参数
image=PhotoImage(file="...")传递。 2、如果需要显示jpg,需要安装PIL,改用ImageTk.Photoimage。
标签: python-3.x tkinter