【发布时间】:2018-04-25 11:39:15
【问题描述】:
我不知道为什么这不起作用。我在 Mac 上使用 python 3。我努力了 label.image 但它不起作用。这是我的代码:
File=open("/Users/user/Desktop/Python/File.txt")
FileContents=File.readlines()
ThingAmount=Team[0]
ActiveThing=Team[1]
ActiveThingImage=PhotoImage("/Users/user/Desktop/Python/"+ActiveThing+"/"+ActiveThing+".gif")
EnemyThingImage=PhotoImage("/Users/user/Desktop/Python/Enemy/EnemyThing.gif")
ActiveThingLabel=Label(window,image=ActiveThingImage)
ActiveThingLabel.image=ActiveThingImage
ActiveThingLabel.place(x=0,y=0)
EnemyThingLabel=Label(window,image=EnemyThingImage)
EnemyThingLabel.place(x=100,y=100)
【问题讨论】:
-
请创建一个minimal reproducible example。一小块漂浮在空中的代码是不够的。
-
您在此处发布的代码是否与您的本地代码相同?看起来您在
ActiveThingImage=行中缺少"引号 -
@BryanOakley 这是我能得到的最完整和可验证的内容
-
它的完整之处是什么?如果我运行它,我会收到多个错误。例如,你没有任何导入,你有不平衡的引号,你没有调用
mainloop,你没有创建一个根窗口,变量window,Team,和`Active_Pokemon_Sprint"是未定义,仅列出最明显的问题。 -
@BryanOakley 首先,很明显我做了导入和窗口,这是标准的,其次,我搞砸了一些变量,我的错,只是告诉我而不是链接无用的文章。我现在记得为什么我首先停止使用 stackoverflow。
标签: python python-3.x tkinter