如何将使用多个图像资源的TKINTER脚本转换为.exe |图像没有这样的文件或目录
我正在尝试创建脚本的可执行文件,但是运行.exe找不到图像。我已经尝试了OneFile和Multiples并将其粘贴在内部,但它不起作用。
这些将是我的图像。
root = Tk()
root.title("Tai Project")
root.geometry("600x600")
root.resizable(0, 0)
img = PhotoImage(file="Tai_Project\ccc.png")
img_opo = PhotoImage(file="Tai_Project\opo.png")
img_label = PhotoImage(file="Tai_Project\labeltest.png")
I am trying to create an executable of my script, but running the .exe does not find the image. I have tried both onefile and multiples and pasting the images inside but it does not work.
These would be my images.
root = Tk()
root.title("Tai Project")
root.geometry("600x600")
root.resizable(0, 0)
img = PhotoImage(file="Tai_Project\ccc.png")
img_opo = PhotoImage(file="Tai_Project\opo.png")
img_label = PhotoImage(file="Tai_Project\labeltest.png")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在所有路径上使用此功能:
用法示例:
在您的.spec文件中,您需要在“数据”部分中匹配类似的目录:
这样的方式将您的文件包含在.exe中,并且将在temp目录中使用,运行程序时创建。
You can use this function for all paths:
Usage example:
Also in your .spec file you need to match directories in "datas" section like this:
This way your files will be included in .exe and will be available in TEMP directory which is created when you run your program.
实际上.spec
Actually .spec