python围棋代码程序设计

_tkinter.TclError: couldn't open "./Pictures/W.png": no such file or directory
为什么啊?明明桌面上已经有pictures这个文档了
Python 已崩溃

img

img

应该是要跟程序运行的地方,在同一个目录下

  • 建议你看下这篇博客👉 :【python】关于_tkinter.TclError: image "pyimage1" doesn't exist 问题的解决办法
  • 除此之外, 这篇博客: 报错_tkinter.TclError: couldn‘t recognize data in image file “D:\images\1 (10).jpg“中的 python报错_tkinter.TclError: couldn’t recognize data in image file “D:\images\1 (10).jpg” 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 练习用label部件显示图片和文本的代码:

    import tkinter as tk
     
    filename = 'D:\\images\\1 (10).jpg'
    root = tk.Tk()
    photo = tk.PhotoImage(file=filename)
    label1 = tk.Label(root,text='学习python', justify='left', 
                      image=photo,compound='center',font=('Consolas',10),fg='white')
    label1.pack()
    root.mainloop()
    
    

    运行报错

    _tkinter.TclError: couldn't recognize data in image file "D:\images\1 (10).jpg"
    
    

    把后缀改成.gif,报错依旧,去找了张真正的gif图(如下)
    在这里插入图片描述
    运行效果:
    在这里插入图片描述
    还是静态的???看来是只改后缀是不行的,要用工具(PS,格式工厂什么的软件)将.jpg或.png图片转化成.gif图片格式才可以
    新的问题又产生了:动态图在窗口显示的只是静态的,怎么使之如原来一样动起来呢?
    查找到的解决方法:使用tkinter显示动态gif