I've set a function to insert the choice of play into the entry box but I am having trouble with using the PLAY button to get that choice and then use the if/else statement to declare the winner? It inserts the choice but when i press play, it just deletes the choice and nothing else is inserted. Any Ideas? Thank you very much! This is my code so far and any tips would be great if possible. If not, just the answer to the question would be perfect!
from tkinter import *
from PIL import ImageTk, Image
import tkinter.font as font
from random import randint
#Fix Frame
root = Tk()
root.title('Rock Paper Scissors')
root.configure(background ='peach puff' )
def clicked(type):
global current
current = e.get()
global t
global computer
global player
e.delete(0, END)
e.insert(0, str(current) + type)
def play():
global t
global computer
global player
global current
e.delete(0, END)
if player == computer:
e.insert("Tie!")
elif player == 'Paper':
if computer == 'Scissors':
e.insert(0, 'You Lose! ' + computer + ' cuts' + str(current))
else:
e.insert(0, 'You Win! ' + str(current) + ' covers ' + computer)
elif player == 'Rock':
if computer == 'Paper':
e.insert(0,'You Lose! ' + computer + ' covers ' + str(current))
else:
e.insert(0, 'You Win! ' + str(current) + ' smashes ' + computer)
elif player == 'Scissors':
if computer == 'Rock':
e.insert(0, 'You Lose! ' + computer + 'smashes' + str(current))
else:
e.insert(0, 'You Win! ' + str(current) + 'cuts' + computer)
rock_butt = Button(root, image=rock_photo,command=lambda:clicked(t[0]))
paper_butt = Button(root, image=paper_photo ,command=lambda:clicked(t[1]))
scissors_butt = Button(root, image=scissor_photo ,command=lambda: clicked(t[2]))
play_butt = Button(root, text= 'Play', padx=60, pady=20, command=play)
quit_butt = Button(root, text= 'Quit Program',bg='light sea green', padx= 40, pady=40, fg='OliveDrab1', command = root.quit)