小编Sil*_*123的帖子

Python函数无法正常工作--Tkinter

我的功能是没有给我正确的输出,它不想工作.我一直收到这个错误:

TypeError: list indices must be integers, not str
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

    def showShop(level = level, cash = cash):
      top = Tkinter.Tk()
      shop = ["$100 & level 2 - Shotgun", "$250 & level 3 - 5 Grenades", "$500 & level 5 - Rocket Launcher"]
      buttons = []
      for i in shop:
        temp = shop[i]
        temp = Tkinter.Button(top, height=10, width=100, text = temp, command = shopping(i))
        temp.pack()
        buttons.append(temp)
      top.mainloop()
Run Code Online (Sandbox Code Playgroud)

我希望它根据它是什么按钮显示商店列表中的内容...

python tkinter function list python-2.7

0
推荐指数
1
解决办法
107
查看次数

标签 统计

function ×1

list ×1

python ×1

python-2.7 ×1

tkinter ×1