0

This is on a repl and all the files are saved on it, but every time I run it it gives me a blank square where the images should be, I am trying to make it randomly produce 3 of the 5 images I have and put them next to each other above the buttons and as said before it just gives me blank squares, I tried using .griid as well but still didn't work. Also If anyone knows why this is could they explain why this is happening and also a solution, it would really help me learn. Thanks In Advance

from PIL import ImageTk, Image
import random

global coinAmount
coinAmount = 100

SpinSigns = ("Banana", "Bell", "Cherry", "Dollar", "Skull")

 

def click1():
 SpinSigns = ("Banana", "Bell", "Cherry", "Dollar", "Skull")
 randomNumber = random.randint(0,4)
 randomSign = SpinSigns[randomNumber]
 
 BananaCount = 0
 BellCount = 0
 CherryCount = 0
 DollarCount = 0
 SkullCount = 0
 x = 0
 while x < 3:
   COLUMN = 0
   if randomSign == "Banana":
     bananaImage= ImageTk.PhotoImage(Image.open("BananaSign.png"))
     SpinSymbol = Label(image = bananaImage)
     SpinSymbol.pack()
     BananaCount += 1
     
   elif randomSign == "Bell":
     bellImage = ImageTk.PhotoImage(Image.open("BellSign.png"))
     SpinSymbol = Label(image = bellImage)
     SpinSymbol.pack()
     BellCount += 1
 
   elif randomSign == "Cherry":
     cherryImage = ImageTk.PhotoImage(Image.open("CherrySign.png"))
     SpinSymbol = Label(image = cherryImage)
     SpinSymbol.pack()
     CherryCount += 1
 
   elif randomSign == "Dollar":
     dollarImage = ImageTk.PhotoImage(Image.open("DollarSign.png"))
     SpinSymbol = Label(image = dollarImage)
     SpinSymbol.pack()
     DollarCount += 1
 
   elif randomSign == "Skull":
     skullImage = ImageTk.PhotoImage(Image.open("SkullSign.png"))
     SpinSymbol = Label(image = skullImage)
     SpinSymbol.pack()
     SkullCount += 1
 
   COLUMN += 1
   x += 1

 
def click2():
 print("Cashy")

texts = "stuf"
 
window = Tk()
#window.geometry("600x450")
lever = Button(window, text = "Pull Me!", command = click1)
cashout = Button(window, text = "Cash Out?", command = click2)

coins = Label(text = coinAmount)
#coins.grid(row = 0, column = 0)


#image1 = ImageTk.PhotoImage(Image.open("BellSign.png"))

#label1 = Label(image = image1)
#label1.grid(row = 0, column = 0)

lever.pack()
cashout.pack()
window.mainloop()

0 Answers0