Write rock-paper-scissors games

Let’s develop the same game using Python 3 and Tkinter. We could name the game Rock-paper-scissors-Lizard Spock.

Rules and Gameplay

  1. Rock crushes Scissors
  2. Rock crushes Lizard
  3. Paper covers Rock
  4. Paper disproves Spock
  5. Scissors cuts Paper
  6. Scissors decapitates Lizard
  7. Lizard poisons Spock
  8. Lizard eats paper
  9. Spock smashes Scissors
  10. Spock vaporizes Rock
  11. Two same objects is a draw

Application practice

When users run the program, they must click on one of the five available objects:

  • Rock
  • Paper
  • Scissors
  • Lizard
  • Spock

When the user selects an object, our program selects an object at random. It will then declare whether the user wins, loses, or draws the game through a set of rules. The results are displayed in the second line of the application.

When the user presses any button, the game restarts. If the user wants to close the game, they can press the Close button. At the beginning of the game, we have hand symbols for certain objects. Now, when the user selects an object, it is converted to a graphical image. Our program also selects an object that displays a graphical image of the selected object.

Python Tkinter Tutorial Series 01: Writing a simple rock-paper-Scissors game

Implementation in Python (10 steps)

Now that we have the meaning of the rock-paper-Scissors game, let’s step through the Python process.

1. Import required libraries

#Import the required libraries :
from tkinter import *
import random
import simpleaudio as sa
Copy the code
  • tkinter: Add widgets to our application
  • random: Generates a random number
  • simpleaudio: Plays a sound file

2. Create the Tkinter main window

root = Tk()
root.configure(bg="#000000")
root.geometry('+0+0')
root.iconbitmap("Game.ico")
root.title("Rock-Paper-Scissor-Lizard-Spock")
root.resizable(width=False,height=False)
Copy the code
  • root = Tk( ): used to initialize our tkinter module.
  • root.configure( ): We use it to specify the background color of the application. In our case, the background color is black.
  • root.geometry( ): We use it to specify where our application window will open. It will open in the upper left corner.
  • root.iconbitmap( ): We use it to set the icon in the title bar of the application window. This feature is only accepted.icoFile.
  • root.title( ): We use it to set the title of the application.
  • root.resizable( )Here we use it to prevent the user from resizing the main window.

3. Import the sound file

#To play sound files : 
start = sa.WaveObject.from_wave_file("Start.wav")
Win = sa.WaveObject.from_wave_file("Win.wav")
Lose = sa.WaveObject.from_wave_file("Lose.wav")
Draw = sa.WaveObject.from_wave_file("Draw.wav")

start.play()
Copy the code

Now, we’ll use some sound files that will play at various events. When our program starts, it will play the start file. When the user wins the game, loses the game, or draws the game, we play the other three files.

One thing to note is that it only accepts.wav files. First, we need to load the sound file into the object. Then we can.play() use the method to play it as needed.

4. Load images for our application

We will use various images in our application. To use these images first, we need to load them. In this case, we’ll load the image using the PhotoImage class.

#Hand images :
rockHandPhoto = PhotoImage(file="Rock_1.png")
paperHandPhoto = PhotoImage(file="Paper_1.png")
scissorHandPhoto = PhotoImage(file="Scissor_1.png")
lizardHandPhoto = PhotoImage(file="Lizard_1.png")
spockHandPhoto = PhotoImage(file="Spock_1.png")

#Graphical images :
rockPhoto = PhotoImage(file="Rock_P.png")
paperPhoto = PhotoImage(file="Paper_P.png")
scissorPhoto = PhotoImage(file="Scissor_P.png")
lizardPhoto = PhotoImage(file="Lizard_P.png")
spockPhoto = PhotoImage(file="Spock_P.png")

#Decision image :
decisionPhoto = PhotoImage(file="Decision_Final.png")

#Result images :
winPhoto = PhotoImage(file="G_WIN.png")
losePhoto = PhotoImage(file="G_LOST.png")
tiePhoto = PhotoImage(file="G_DRAW.png")
Copy the code

First, we prepared an image of the hand for the object. All five images are shown to the user at the start of the game. The user must select an object from those images.

After the user clicks on the image, our program will show us a graphical image of the object. You must select an object, and our program will select an object. Our program will display only these two graphic images, then the rest of the images will disappear.

Now we display a simple decision image that changes its image when the results are available. Our results have different images.

  • If the user wins
  • If the user loses
  • If there’s a tie

5. Add the Tkinter widget

#Initialize the button variables :
rockHandButton = " "
paperHandButton = " "
scissorHandButton = " "
lizardHandButton= " "
spockHandButton = " "

#Create the result button :
resultButton = Button(root,image=decisionPhoto)

#Set the variable to True
click = True
Copy the code
  • Initialize variables for five buttons.
  • Here, we create the Results button, which will show us the final result.
  • We set the click variable toTrueSo that our program can continue running until it is set toFalse. We’ll see more about this in the next few points.

6. Play()

def play():
    global rockHandButton,paperHandButton,scissorHandButton,lizardHandButton,spockHandButton

    #Set images and commands for buttons :
    rockHandButton = Button(root,image = rockHandPhoto, command=lambda:youPick("Rock"))
    paperHandButton = Button(root,image = paperHandPhoto, command=lambda:youPick("Paper"))
    scissorHandButton = Button(root,image = scissorHandPhoto, command=lambda:youPick("Scissor"))
    lizardHandButton = Button(root,image= lizardHandPhoto,command=lambda:youPick("Lizard"))
    spockHandButton = Button(root,image= spockHandPhoto,command=lambda:youPick("Spock"))

    #Place the buttons on window :
    rockHandButton.grid(row=0,column=0)
    paperHandButton.grid(row=0,column=1)
    scissorHandButton.grid(row=0,column=2)
    lizardHandButton.grid(row=0,column=3)
    spockHandButton.grid(row=0,column=4)

    #Add space :
    root.grid_rowconfigure(1, minsize=50) 

    #Place result button on window : 
    resultButton.grid(row=2,column=0,columnspan=5)
Copy the code

Here, we create a button for the object. We will set up the image for the button, which will work with youPick() with the string name of the object clicked when the button is pressed.

You then use the.grid() method to arrange the buttons on the main window. Here, we add a space on the first line. Grid_rowconfigure (). Then, place the result button on the second line. We are using columnSPAN to center the result button.

7. It’s the computer’s turn

Our computer will randomly select one of the five available objects and return a string value for that.

def computerPick():
    choice = random.choice(["Rock","Paper","Scissor","Lizard","Spock"])
    return choice
Copy the code

8. Main Function: youPick()

In this function, our program displays a graphical image of the selected object. It will delete the remaining objects. It also applies a set of rules to generate results.

def youPick(yourChoice):
    global click
        compPick = computerPick()
        if click==True:
Copy the code

We store the computer’s choices in the compPick variable. We will use it to determine the result.

User selects Rock:

If the user selects Rock, this code block is used. The commands in the play() function are sent along a string that represents the object selected by the user. We store it in yourChoice variable. Now, computers have five possibilities.

Now we have to make rules for each rule. Now note that when users and computers select an object, they are not allowed to make changes to it. Therefore, we change the click variable to False.

Now that the user has selected Rock we want our first image to turn into a graphic image of the Rock. Now, if the computer selects Rock, then we want our second image to become a graphical image. To change the image of the button, we use the.configure() method.

We want the other three images to disappear. To make them disappear, we use.grid_forget(). It will also play drawing audio. Now let’s develop similar rules for the rest of the objects.

def computerPick():choice = random.choice(["Rock","Paper","Scissor","Lizard","Spock"])return choice
Copy the code

User selection of paper:

See the rules above for the rules when the user selects paper. Take a look at the code below, which follows the same rules as Rock.

elif yourChoice == "Paper":rockHandButton.configure(image=paperPhoto)if compPick == "Rock":paperHandButton.configure(image=rockPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_forget()l izardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelif compPick == "Paper":paperHandButton.configure(image=paperPhoto)resultButton.configure(image=tiePhoto)scissorHandButton.grid_forget() lizardHandButton.grid_forget()spockHandButton.grid_forget()Draw.play()click = Falseelif compPick == "Scissor":paperHandButton.configure(image=scissorPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_for get()lizardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelif compPick =="Lizard":paperHandButton.configure(image=lizardPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_for get()lizardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelse :paperHandButton.configure(image=spockPhoto)resultButton.configure(image=winPhoto)scissorHandButton.grid_forget()lizardH andButton.grid_forget()spockHandButton.grid_forget()Win.play()click = FalseCopy the code

User selects scissors:

Please view the rules from the top to understand the rules when users select scissors. Take a look at the code below, which follows the same rules as Rock and Paper.

elif yourChoice=="Scissor":rockHandButton.configure(image=scissorPhoto)if compPick == "Rock":paperHandButton.configure(image=rockPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_forget()l izardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelif compPick == "Paper":paperHandButton.configure(image=paperPhoto)resultButton.configure(image=winPhoto)scissorHandButton.grid_forget() lizardHandButton.grid_forget()spockHandButton.grid_forget()Win.play()click = Falseelif compPick=="Scissor":paperHandButton.configure(image=scissorPhoto)resultButton.configure(image=tiePhoto)scissorHandButton .grid_forget()lizardHandButton.grid_forget()spockHandButton.grid_forget()Draw.play()click = Falseelif compPick == "Lizard":paperHandButton.configure(image=lizardPhoto)resultButton.configure(image=winPhoto)scissorHandButton.grid_forget ()lizardHandButton.grid_forget()spockHandButton.grid_forget()Win.play()click = Falseelse:paperHandButton.configure(image=spockPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_forge t()lizardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = FalseCopy the code

User selects “Lizard”

See the rules above to see how the user chooses the lizard. Look at the code below, which follows the same rules as the rest of the code.

elif yourChoice=="Lizard":rockHandButton.configure(image=lizardPhoto)if compPick == "Rock":paperHandButton.configure(image=rockPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_forget()l izardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelif compPick == "Paper":paperHandButton.configure(image=paperPhoto)resultButton.configure(image=winPhoto)scissorHandButton.grid_forget() lizardHandButton.grid_forget()spockHandButton.grid_forget()Win.play()click = Falseelif compPick=="Scissor":paperHandButton.configure(image=scissorPhoto)resultButton.configure(image=losePhoto)scissorHandButto n.grid_forget()lizardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelif compPick == "Lizard":paperHandButton.configure(image=lizardPhoto)resultButton.configure(image=tiePhoto)scissorHandButton.grid_forget ()lizardHandButton.grid_forget()spockHandButton.grid_forget()Draw.play()click = Falseelse:paperHandButton.configure(image=spockPhoto)resultButton.configure(image=winPhoto)scissorHandButton.grid_forget ()lizardHandButton.grid_forget()spockHandButton.grid_forget()Win.play()click = FalseCopy the code

User selects Spock:

You can view the rules above to learn about the rules for selecting Spock. Look at the code below, which follows the same rules as the rest of the code.

elif yourChoice=="Spock":rockHandButton.configure(image=spockPhoto)if compPick == "Rock":paperHandButton.configure(image=rockPhoto)resultButton.configure(image=winPhoto)scissorHandButton.grid_forget()li zardHandButton.grid_forget()spockHandButton.grid_forget()Win.play()click = Falseelif compPick == "Paper":paperHandButton.configure(image=paperPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_forget( )lizardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelif compPick=="Scissor":paperHandButton.configure(image=scissorPhoto)resultButton.configure(image=winPhoto)scissorHandButton .grid_forget()lizardHandButton.grid_forget()spockHandButton.grid_forget()Win.play()click = Falseelif compPick == "Lizard":paperHandButton.configure(image=lizardPhoto)resultButton.configure(image=losePhoto)scissorHandButton.grid_forge t()lizardHandButton.grid_forget()spockHandButton.grid_forget()Lose.play()click = Falseelse:paperHandButton.configure(image=spockPhoto)resultButton.configure(image=tiePhoto)scissorHandButton.grid_forget ()lizardHandButton.grid_forget()spockHandButton.grid_forget()Draw.play()click = FalseCopy the code

9. Play again

After you get the results, if you want to play them again, just click any button. It will be converted to the original hand image. Now, we have to retrieve the missing images. We set the value of the click variable to True. We will then play the start sound file so that the audio will play when the user enters the new game.

 else:
        #To reset the game :
        if yourChoice=="Rock" or yourChoice=="Paper" or yourChoice=="Scissor" or yourChoice=="Lizard" or yourChoice=="Spock":
            rockHandButton.configure(image=rockHandPhoto)
            paperHandButton.configure(image=paperHandPhoto)
            scissorHandButton.configure(image=scissorHandPhoto)
            lizardHandButton.configure(image=lizardHandPhoto)
            spockHandButton.configure(image=spockHandPhoto)
            resultButton.configure(image=decisionPhoto)

            #Get back the deleted buttons :
            scissorHandButton.grid(row=0,column=2)
            lizardHandButton.grid(row=0,column=3)
            spockHandButton.grid(row=0,column=4)

            #Set click = True :
            click=True

            #Play the sound file :
            start.play()
Copy the code

10. Call the function

Now we call the play function, which handles the rest of the functions internally. To close the application, press the Close button on the title bar.

#Calling the play function :
play()

#Enter the main loop :
root.mainloop()
Copy the code

Put together

See the full code for this Python Tkinter game (IT station).

#Import the required libraries :
from tkinter import *
import random
import simpleaudio as sa

root = Tk()
root.configure(bg="#000000")
root.geometry('+0+0')
root.iconbitmap("Game.ico")
root.title("Rock-Paper-Scissor-Lizard-Spock")
root.resizable(width=False,height=False)

#To play sound files : 
start = sa.WaveObject.from_wave_file("Start.wav")
Win = sa.WaveObject.from_wave_file("Win.wav")
Lose = sa.WaveObject.from_wave_file("Lose.wav")
Draw = sa.WaveObject.from_wave_file("Draw.wav")

start.play()

#Hand images :
rockHandPhoto = PhotoImage(file="Rock_1.png")
paperHandPhoto = PhotoImage(file="Paper_1.png")
scissorHandPhoto = PhotoImage(file="Scissor_1.png")
lizardHandPhoto = PhotoImage(file="Lizard_1.png")
spockHandPhoto = PhotoImage(file="Spock_1.png")

#Graphical images :
rockPhoto = PhotoImage(file="Rock_P.png")
paperPhoto = PhotoImage(file="Paper_P.png")
scissorPhoto = PhotoImage(file="Scissor_P.png")
lizardPhoto = PhotoImage(file="Lizard_P.png")
spockPhoto = PhotoImage(file="Spock_P.png")

#Decision image :
decisionPhoto = PhotoImage(file="Decision_Final.png")

#Result images :
winPhoto = PhotoImage(file="G_WIN.png")
losePhoto = PhotoImage(file="G_LOST.png")
tiePhoto = PhotoImage(file="G_DRAW.png")

#Initialize the button variables :
rockHandButton = " "
paperHandButton = " "
scissorHandButton = " "
lizardHandButton= " "
spockHandButton = " "

#Create the result button :
resultButton = Button(root,image=decisionPhoto)

#Set the variable to True
click = True

def play():
    global rockHandButton,paperHandButton,scissorHandButton,lizardHandButton,spockHandButton

    #Set images and commands for buttons :
    rockHandButton = Button(root,image = rockHandPhoto, command=lambda:youPick("Rock"))
    paperHandButton = Button(root,image = paperHandPhoto, command=lambda:youPick("Paper"))
    scissorHandButton = Button(root,image = scissorHandPhoto, command=lambda:youPick("Scissor"))
    lizardHandButton = Button(root,image= lizardHandPhoto,command=lambda:youPick("Lizard"))
    spockHandButton = Button(root,image= spockHandPhoto,command=lambda:youPick("Spock"))

    #Place the buttons on window :
    rockHandButton.grid(row=0,column=0)
    paperHandButton.grid(row=0,column=1)
    scissorHandButton.grid(row=0,column=2)
    lizardHandButton.grid(row=0,column=3)
    spockHandButton.grid(row=0,column=4)

    #Add space :
    root.grid_rowconfigure(1, minsize=50) 

    #Place result button on window : 
    resultButton.grid(row=2,column=0,columnspan=5)

def computerPick():
    choice = random.choice(["Rock","Paper","Scissor","Lizard","Spock"])
    return choice

def youPick(yourChoice):
    global click

    compPick = computerPick()

    if click==True:

        if yourChoice == "Rock":

            rockHandButton.configure(image=rockPhoto)

            if compPick == "Rock":
                paperHandButton.configure(image=rockPhoto)
                resultButton.configure(image=tiePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Draw.play()
                click = False

            elif compPick == "Paper":
                paperHandButton.configure(image=paperPhoto)
                scissorHandButton.grid_forget()
                resultButton.configure(image=losePhoto)
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()

                click = False

            elif compPick == "Scissor":
                paperHandButton.configure(image=scissorPhoto)
                scissorHandButton.grid_forget()
                resultButton.configure(image=winPhoto)
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            elif compPick =="Lizard":
                paperHandButton.configure(image=lizardPhoto)
                scissorHandButton.grid_forget()
                resultButton.configure(image=winPhoto)
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            else :
                paperHandButton.configure(image=spockPhoto)
                scissorHandButton.grid_forget()
                resultButton.configure(image=losePhoto)
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

        elif yourChoice == "Paper":
            rockHandButton.configure(image=paperPhoto)

            if compPick == "Rock":
                paperHandButton.configure(image=rockPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            elif compPick == "Paper":
                paperHandButton.configure(image=paperPhoto)
                resultButton.configure(image=tiePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Draw.play()
                click = False

            elif compPick == "Scissor":
                paperHandButton.configure(image=scissorPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            elif compPick =="Lizard":
                paperHandButton.configure(image=lizardPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            else :
                paperHandButton.configure(image=spockPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

        elif yourChoice=="Scissor":
            rockHandButton.configure(image=scissorPhoto)
            if compPick == "Rock":
                paperHandButton.configure(image=rockPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            elif compPick == "Paper":
                paperHandButton.configure(image=paperPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            elif compPick=="Scissor":
                paperHandButton.configure(image=scissorPhoto)
                resultButton.configure(image=tiePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Draw.play()
                click = False

            elif compPick == "Lizard":
                paperHandButton.configure(image=lizardPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            else:
                paperHandButton.configure(image=spockPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

        elif yourChoice=="Lizard":
            rockHandButton.configure(image=lizardPhoto)
            if compPick == "Rock":
                paperHandButton.configure(image=rockPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            elif compPick == "Paper":
                paperHandButton.configure(image=paperPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            elif compPick=="Scissor":
                paperHandButton.configure(image=scissorPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            elif compPick == "Lizard":
                paperHandButton.configure(image=lizardPhoto)
                resultButton.configure(image=tiePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Draw.play()
                click = False

            else:
                paperHandButton.configure(image=spockPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

        elif yourChoice=="Spock":
            rockHandButton.configure(image=spockPhoto)
            if compPick == "Rock":
                paperHandButton.configure(image=rockPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            elif compPick == "Paper":
                paperHandButton.configure(image=paperPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            elif compPick=="Scissor":
                paperHandButton.configure(image=scissorPhoto)
                resultButton.configure(image=winPhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Win.play()
                click = False

            elif compPick == "Lizard":

                paperHandButton.configure(image=lizardPhoto)
                resultButton.configure(image=losePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Lose.play()
                click = False

            else:
                paperHandButton.configure(image=spockPhoto)
                resultButton.configure(image=tiePhoto)
                scissorHandButton.grid_forget()
                lizardHandButton.grid_forget()
                spockHandButton.grid_forget()
                Draw.play()
                click = False

    else:
        #To reset the game :
        if yourChoice=="Rock" or yourChoice=="Paper" or yourChoice=="Scissor" or yourChoice=="Lizard" or yourChoice=="Spock":
            rockHandButton.configure(image=rockHandPhoto)
            paperHandButton.configure(image=paperHandPhoto)
            scissorHandButton.configure(image=scissorHandPhoto)
            lizardHandButton.configure(image=lizardHandPhoto)
            spockHandButton.configure(image=spockHandPhoto)
            resultButton.configure(image=decisionPhoto)

            #Get back the deleted buttons :
            scissorHandButton.grid(row=0,column=2)
            lizardHandButton.grid(row=0,column=3)
            spockHandButton.grid(row=0,column=4)

            #Set click = True :
            click=True

            #Play the sound file :
            start.play()

#Calling the play function :
play()

#Enter the main loop :
root.mainloop()
Copy the code