PYTHON3.5,tkinter,一直提示image "pyimage1" doesn't exist 我的1.png是存在的,请问为什么会这样?
fromtkinterimport*defa():root=Tk()image1=PhotoImage(file='1.png')Label1=Label(root,im...
from tkinter import *
def a():
root = Tk()
image1 = PhotoImage(file = '1.png')
Label1 = Label(root,image = image1)
Label1.pack()
root.mainloop()
def play():
top = Tk()
Button1 = Button(top,command = a)
Button1.pack()
top.mainloop()
play() 展开
def a():
root = Tk()
image1 = PhotoImage(file = '1.png')
Label1 = Label(root,image = image1)
Label1.pack()
root.mainloop()
def play():
top = Tk()
Button1 = Button(top,command = a)
Button1.pack()
top.mainloop()
play() 展开
2个回答
展开全部
改成绝对路径试一下咯
更多追问追答
追问
不行……
追答
from os.path import exists
fname='1.png'
print(exists(fname))
用这个测试一下先吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询