Python 2.7 TKINTER库中的图像错误
我使用Python 2.7与TKINTER创建图形接口(对于ArcGIS脚本),但是当我想将壁纸加载到接口中时,它会给我错误 “ _tkinter.tclerror:无法在图像文件[图像路径]中识别数据” 我在互联网上搜索了各种解决方案,最好的解决方案是PIL库。 找不到其他解决方案? 以下是书面代码。谢谢
from Tkinter import *
import os
ROOT_PATH = os.getcwd()
window = Tk()
window.title("Update TXT field")
window.geometry("950x350")
window.config(bg = "white")
canvas = Canvas(window, width = 900, height = 350, bg = "white")
canvas.grid(row = 0, column = 1)
img = PhotoImage(file=os.path.join(ROOT_PATH, "logo.png"))
image = canvas.create_image(861,320, image=img)
canvas.pack()
label_path = Label(text = "Add path to folder:")
label_path.grid(row = 1, column = 0)
path_entry = Entry(width = 35)
path_entry.grid(row = 1, column = 1)
button = Button()
window.mainloop()
I use python 2.7 to create a graphical interface with Tkinter (for an arcgis script) but when I want to load wallpaper in the interface, it gives me the error
"_tkinter.TclError: could not recognize data in image file [path to image]"
I searched the internet for various solutions and the best one would be with the PIL library.
Can't find another solution?
Below is the written code. Thanks
from Tkinter import *
import os
ROOT_PATH = os.getcwd()
window = Tk()
window.title("Update TXT field")
window.geometry("950x350")
window.config(bg = "white")
canvas = Canvas(window, width = 900, height = 350, bg = "white")
canvas.grid(row = 0, column = 1)
img = PhotoImage(file=os.path.join(ROOT_PATH, "logo.png"))
image = canvas.create_image(861,320, image=img)
canvas.pack()
label_path = Label(text = "Add path to folder:")
label_path.grid(row = 1, column = 0)
path_entry = Entry(width = 35)
path_entry.grid(row = 1, column = 1)
button = Button()
window.mainloop()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论