XLouis

博客园 首页 新随笔 联系 订阅 管理
  19 随笔 :: 4 文章 :: 2 评论 :: 6494 阅读
复制代码
import tkinter as tk   #导入Tkinter
from PIL import Image, ImageTk
root = tk.Tk()
root.title('图片演示')  #设置窗口标题
root.geometry('759x500')
photo=Image.open(fr"C:\\Users\\Lenovo\\Desktop\\选股系统\\界面2.jpg")    #读入数据
img=ImageTk.PhotoImage(photo)  #转换为Tkinter图像格式
label_img = tk.Label(root, image=img).grid(row=0, column=0)   
label_img.pack()
root.mainloop()
复制代码
复制代码
TclError                                  Traceback (most recent call last)
<ipython-input-18-215e4be4b67c> in <module>
      6 photo=Image.open("界面2.jpg")    #读入数据
      7 img=ImageTk.PhotoImage(photo)  #转换为Tkinter图像格式
----> 8 label_img = tk.Label(root, image=img).grid(row=0, column=0)
      9 label_img.pack()
     10 root.mainloop()

~\anaconda3\lib\tkinter\__init__.py in __init__(self, master, cnf, **kw)
   3141 
   3142         """
-> 3143         Widget.__init__(self, master, 'label', cnf, kw)
   3144 
   3145 

~\anaconda3\lib\tkinter\__init__.py in __init__(self, master, widgetName, cnf, kw, extra)
   2565         for k, v in classes:
   2566             del cnf[k]
-> 2567         self.tk.call(
   2568             (widgetName, self._w) + extra + self._options(cnf))
   2569         for k, v in classes:

TclError: image "pyimage11" doesn't exist
复制代码

 

posted on   XLouis  阅读(359)  评论(1编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示