'Error: image "pyimage1" doesn't exist (pt2) am new to python btw

I need help with creating a button with an image, the creation of the image seems to not be a problem as when I hover over the file location of the image, the image pops up. However, the error image "pyimage1" doesn't exist shows up as seen in the screenshots. This is for a cookie clicker type game for a school project and I am very knew to Python (3 days of learning so far). Importing OS and using OS.cwd() isn't effective because the file path is correct. Here is my code:

from tkinter import *
import os

from Game import Game

gui = Tk()
gui.title("Clicking Mania")
gui.geometry("600x600")

# Inside GUI title
title = Label(gui, text="Clicking Mania")
title.pack()
title.grid_location(3, 2)

# Images
os.getcwd()
image = PhotoImage(file='../GameImages/DPic.png')
imagelabel = Label(image=image)
imageshop = PhotoImage(file='../GameImages/upgrade.png')
imageupgrade = Label(image=imageshop)

# Buttons
pickaxebutton = Button(gui, image=image, command=Game.clickcmd(1), borderwidth=0)
pickaxebutton.pack(pady=100)
upgradebutton = Button(gui, image=imageshop, borderwidth=0)

# change image
up1button = Button(gui, image=image, command=Game.up1cmd(), borderwidth=0)

balance = Label(gui, text="Balance: ", padx=20, pady=10)
balance.pack()

gui.mainloop()
class Game():
    multiplier = 0

    global upgrades
    upgrades = ["2","4","6","8","10"],["Upgrade 1", "Upgrade 2", "Upgrade 3", "Upgrade 4", "Upgrade 5"]



    def setMultiplier(x):
        multiplier = x
        print(multiplier)


    def clickcmd(multiplier):
        global clicks
        clicks += 1 * (multiplier)
        return clicks



    def up1cmd(x):
        setMultiplier(upgrades[0][x])





    # x = Which upgrade was bought, returns upgrade[x]
    def getUpgrade(x):
        return upgrades[0,x] , upgrades[1,x]


Solution 1:[1]

You have a number of problems in your Game class that you haven't found yet. Two-dimensional arrays in Python are not indexed as [a,b] -- it has to be [a][b]. You don't use global with class variables. And you must use self to access object variables. And it looks like you expect to use the first list as integers, so you need to make them integers. Note that a dictionary would probably be a better choice for upgrades:

class Game:
    multiplier = 0
    clicks = 0
    upgrades = [2,4,6,8,10],["Upgrade 1", "Upgrade 2", "Upgrade 3", "Upgrade 4", "Upgrade 5"]

    def setMultiplier(self, x):
        self.multiplier = x
        print(self.multiplier)

    def clickcmd(self, multiplier):
        self.clicks += multiplier
        return self.clicks

    def up1cmd(self, x):
        self.setMultiplier(self.upgrades[0][x])

    # x = Which upgrade was bought, returns upgrade[x]
    def getUpgrade(self, x):
        return self.upgrades[0][x] , self.upgrades[1][x]

Solution 2:[2]

You're not creating new objects - you're modifying and re-adding the same object to the list multiple times.

A common pattern for solving this is to re-use a dictionary as a template, then cast to [pscustomobject] to create new objects based on it:

$problems = New-Object System.Collections.ArrayList

# Create ordered dictionary to function as object template
$problemTemplate = [ordered]@{
    problemName        = "abc"
    problemDescription = $null
}

# modify template
$problemTemplate.problemDescription = "def"

# create new object, add to list
$problemObj = [pscustomobject]$problemTemplate
$problems.Add($problemObj)

# modify template again
$problemTemplate.problemDescription = "ghi"

# create another object, add to list
$problemObj = [pscustomobject]$problemTemplate
$problems.Add($problemObj)

$problems

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim Roberts
Solution 2 Mathias R. Jessen