So I'm having an issue, whenever I open the shop window, click the Attack Up 1 button, when the command it's attached to runs, it says that the attackUp1 variable is not defined even though it is set to be the widget. Have a peak at my code:
#opens shop canvas where you buy upgrades
def shop():
global shop
root = Tk()
root.title("Shop")
shop = Canvas (root, width = 150, height = 400, bg = "blue")
shop.pack()
attackUp1 = shop.create_window(77, 50, window = Button(shop, text = "Attack Up 1\n20 coins", font = ("calibri" , 20), command = attackIncreaser1))
#attackUp2 = shop.create_window(77, 100, window = Button(shop, text = "Attack Up 2\n60 coins", font = ("calibri" , 20), command = shoot))
#runs when someone buys the attackUp1 upgrade and changes their stats or says that they don't have enough coins
def attackIncreaser1():
global attack
global attackPower
global coins
global shop
global attackUp1
if coins < attackUp1Price:
attackUp1.config(text="Not enough coins")
elif coins >= attackUp1Price:
attackPower = attackPower + 1
attackUp1.config(text="")
time.sleep(0.5)
attackUp1.config(text="Attack Up 1\n20 coins")