ZBLOG

import tkinter as tk root = tk.Tk() root.geometry("400x300") root.title("My Image Viewer") image = tk.PhotoImage(file=r"F:\1\Python\jjb2\电力市场作业\界面工人\1.png") label = tk.Label(root, image=image) label.pack() root.mainlo

可能是图片路径不正确或者图片格式不支持导致的问题。请确认图片路径是否正确,图片格式是否为Tkinter支持的格式(如.gif)。

以下是修改后的例程:

  1. import tkinter as tk
  2. root = tk.Tk()
  3. root.geometry("400x300")
  4. root.title("My Image Viewer")
  5. image = tk.PhotoImage(file=r"path/to/your/image.png")
  6. label = tk.Label(root, image=image)
  7. label.pack()
  8. root.mainloop()

其中,将file参数修改为正确的图片路径即可。

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=4413

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?