无法修复“缺少1个必需的位置参数错误”

时间:2019-11-25 13:24:28

标签: python tkinter

好吧,我正在尝试做一家像东西的商店,您可以将输入的任何东西都放入盒子中,还可以将您输入的东西退回去。袋子/背包有3个插槽。我想出的代码是

    from tkinter import *
window = Tk()
window.title("BagAttempt")
canvas = Canvas(width = 1440, height = 810, bg = 'white')
canvas.pack()

shoplist=["sword","rock","flint","shield","alcohol","stick","bottle"]
backpacklist=[]
def backpackadd(Shopchoice):
    help1=0
    while shoplist[help1]!=Shopchoice:
        help1=help1+1
    if shoplist[help1]==Shopchoice:
        backpacklist.append(shoplist[help1])
        shoplist.remove(shoplist[help1])
    return shoplist,backpacklist
def Shopchoices1():
    canvas.create_rectangle(0,0,1440,810,fill="black")
    canvas.create_text(720,415,text=shoplist,font="Times 25",fill="white")
    canvas.create_text(720,705,text=backpacklist,font="Times 20",fill="white")
    leave=0
    canvas.create_text(720,565,text="What would you like to add/remove/leave:",fill="white",font="Times 10")
    Shopchoice=Entry(canvas,bg="grey",fg="white",font="Times 25")
    Shopchoice_window =canvas.create_window(720,605, anchor="n", window=Shopchoice)
    Add= Button(canvas, text = "Add", command = backpackadd, anchor = "n")
    Add.configure(width = 100, bg="yellow",activebackground = "#FFD700", relief = FLAT)
    Add_window = canvas.create_window(720,475, anchor="n", window=Add)
Shopchoices1()

mainloop()

我一直遇到backpackadd() missing 1 required positional argument: 'Shopchoice'错误。我不确定如何解决它,感谢您的帮助。

0 个答案:

没有答案