Year-End Discount: 10% OFF 1-year and 20% OFF 2-year subscriptions!

Home/Blog/Python Tkinter tutorial: Build a rock-paper-scissors game

# Python Tkinter tutorial: Build a rock-paper-scissors game

Sep 09, 2020 - 8 min read
Pratik Shukla

## Python Tkinter Games Series

• #### Create a F.L.A.M.E.S. game from scratch

This series aims to introduce you to Tkinter, Pythonâ€™s standard interface to the Tk GUI toolkit, and help you build interactive games you can add to your resume. To get up to speed on Tkinter, go read our first article in this series Python Tkinter Tutorial: build a number guessing game. Once you get down the basics, come back here to build a rock-paper-scissors game from scratch!

Today, we will cover:

## Rock-paper-scissors game walkthrough

In this article weâ€™ll develop a modified version of the famous childhood game Rock-Paper-Scissors. If you have watched The Big Bag Theory (season 2, episode 8), Sheldon Cooper expands the Rock-Paper-Scissors game by adding two more objects: Lizard and Spock.

Letâ€™s develop the same game using Python 3 and Tkinter. We can name our game Rock-Paper-Scissors-Lizard-Spock.

### Rules and how to play

1. Rock crushes Scissors

2. Rock crushes Lizard

3. Paper covers Rock

4. Paper disproves Spock

5. Scissors cuts Paper

6. Scissors decapitates Lizard

1. Lizard poisons Spock

2. Lizard eats paper

3. Spock smashes Scissors

4. Spock vaporizes Rock

5. Two same objects is a draw

### Walkthrough of the program

When the user runs the program, they have to click on one of the five available objects:

• Rock
• Paper
• Scissors
• Lizard
• Spock

When the user selects one of the objects, our program will randomly select one object. Then, it will go through the set of rules to declare whether the user won, lost or drew the game. The result will be displayed on the second row of our application.

When the user presses any of the button, the game will restart. If the user wants to close the game then they press the close button. At the start of the game, we have hand symbols for the particular objects. Now, when the user selects an object, it will transform into a graphic image. Our program also selects an object, and it will display the graphical image for the selected object.

Complete flowchart for the game

Start Window (1)
1 of 4

## Implementation in Python (10 steps)

Now that we have a sense of what the rock-paper-scissors game will entail, letâ€™s walk step-by-step through the process in Python. If you donâ€™t yet know how to set up Tkinter, check out our first article in this series for a brief tutorial.

### 1. Import required libraries

#Import the required libraries :from tkinter import *import randomimport simpleaudio as sa
• tkinter: to add widgets in our application
• random: to generate a random number
• simpleaudio: to play the sound files

### 2. Create main tkinter 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)
• root = Tk( ): This is used to initialize our tkinter module.
• root.configure( ): We use this to specify the background color for our application. In our case the background color will be black.
• root.geometry( ): We use this to specify at which location our application window will open. It will open at the top-left corner.
• root.iconbitmap( ): We use it to set the icon in the title bar for our application window. This function only accepts .ico files.
• root.title( ): We use it to set the title for our application.
• root.resizable( ): Here we are using it to prevent the users from resizing our main window.

### 3. Importing sound files

#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()

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

One thing to notice is that it only accepts .wav files. First of all we need to load the sound file in an object. Then we can play it using .play( ) method when required.

We will use various images in our application. To use those images first we need to load those images. Here we are going to use PhotoImage class to load our images.

#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")

First, we have hand images for our objects. All five images will be shown to user at the start of the game. The user has to choose one object from those images.

After the user clicks on an image, our program will show us the graphical image for that object. The has to select one object, and our program will also select one object. Our program will only show those two graphical images, and then rest will disappear.

Now, we display a simple decision image that will change its image when the results are available. We have different images for our results.

• If user wins
• If user loses
• If there is a tie

#Initialize the button variables :rockHandButton = " "paperHandButton = " "scissorHandButton = " "lizardHandButton= " "spockHandButton = " "#Create the result button :resultButton = Button(root,image=decisionPhoto)#Set the variable to Trueclick = True
• Initialize the variable for five buttons.
• Here, we create the result button which will show us the final result.
• We set the click variable to True, so that our program keep running until itâ€™s set to False. We will see more about this in the next points.

### 6. Play( ) function

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)

Here, we create buttons for our objects. We are going to set images for the buttons, and when itâ€™s pressed, it will go to youPick( ) function with the string name of the object clicked.

Then, we arrange the buttons on the main window using the .grid( ) method. Here, weâ€™re adding a blank space in row one with .grid_rowconfigure( ). Then, we place our result button on the second row. Weâ€™re using columnspan to center our result button.

### 7. Computerâ€™s turn

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

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

### 8. Main function: youPick( )

In this function, our program will display the graphical images for the selected objects. It will delete the rest of the objects. It will also apply a set of rules to generate the result.

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

We are storing the computerâ€™s choice in compPick variable. Weâ€™ll use it to decide the result.

User selecting Rock:

This block of code is used if user selects Rock. The command in play( ) function sends along a string that represents the object selected by user. We are storing it in yourChoice variable. Now there are five possibilities for the computer.

Now we have to develop rules for each of them. Now notice that when the user and computer has selected an object they are not allowed to change it. Thatâ€™s why we are changing the click variable to False.

Now, since the user has selected Rock we want our first image to turn into graphical image for rock. Now if the computer chooses Rock, then we want our second image to turn into graphical image. To change the image of a button, we use .configure( ) method.

We want the rest of the three images to disappear. To make them disappear we use .grid_forget( ). It will also play the draw audio. Now, we develop similar rule for the rest of the objects.

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

User selecting Paper:

See the rules from above to understand the rules for when the user selects Paper. 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()                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

User selecting Scissors:

See the rules from above to understand the rules for when the user selects Scissors. 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()                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

User selecting lizard

See the rules from above to understand the rules for when the user selects Lizard. Look at the code below, which follows the same rules as the others.

  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

User choosing Spock:

See the rules from above to understand the rules for when the user selects Spock. Look at the code below, which follows the same rules as the others.

   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

### 9. Play Again

After we get our results, if we want to play again, we simply have to click on any of the buttons. It will transform it to original hand images. Now, we have to get back those disappeared images. We will set the value of click variable to True. Then, we will play the start sound file so that when the user enters a new game, audio will be played.

 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()

### 10. Call the function

Now we call the play function, and itâ€™ll take care of the rest of the functions internally. To close the application, we press the close button on the title bar.

#Calling the play function :play()#Enter the main loop :root.mainloop()

## Putting it all together

Take a look at the complete code for this Python Tkinter game.

#Import the required libraries :from tkinter import *import randomimport simpleaudio as saroot = 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 Trueclick = Truedef 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 choicedef 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()

## Wrapping up and resources

Congrats! Youâ€™ve reached the end and built a successful Python Tkinter game. Great work applying your Python knowledge. I hope you enjoyed this article and learned something new from it.

Python is such an intuitive programming language that the easiest way to master it is through hands-on practice like this. Keep up the work and keep building!

In this series on Tkinter, weâ€™ll be developing a total of Five games using Tkinter. So, hang tight! If you have any doubts, questions, or thoughts regarding this article, feel free to contact me at shuklapratik22@gmail.com

### Continue learning

WRITTEN BYPratik Shukla

Join a community of more than 1.4 million readers. A free, bi-monthly email with a roundup of Educative's top articles and coding tips.

Learn in-demand tech skills in half the time