DEV Community

JRRyan606
JRRyan606

Posted on

Rock, Paper, Scissors game in Python

Hey there, this is a simple GUI-Based Rock Paper Scissors game in python.

Link to the github repo: https://github.com/JRRyan606/Rock-Paper-Scissors-Tk-Gui

IMPORTANT, PLEASE READ THIS:

The credit for this project MUST go to Bro code, He made a video in his Youtube channel called Python rock, paper, scissors game where he created a CLI-Based rock, paper, scissors game in python. I have created the GUI version of it. There are some features that Bro code created in his rock, paper, scissors game that is NOT YET coded in my gui version of the game. I will be coding it soon...

Link to Bro code's Youtube channel: https://www.youtube.com/channel/UC4SVo0Ue36XCfOyb5Lh1viQ

Link to the Python rock, paper, scissors game Youtube video: https://youtu.be/GhPZHvhvlsk

If you want to address any bugs on this project or some improvements that can be made on this project, feel free to email me about it at: ryanjustin25706@gmail.com

This is my first Tkinter project using Python, any improvements or suggestions is highly appreciated!!. Thanks.

For those of you who have some problems seeing the code from the above github link, here's is the code:

from tkinter import *
import random

win = Tk()
win.title("Rock, Paper, Scissors")
win.geometry("801x300")


options = ["rock", "paper", "scissors"]
computer = random.choice(options)




def show():
    info = "Computer choose: " + computer
    info2 = "You choose: " + str(e.get()).lower()
    if str(e.get()).lower() == computer:
        text3 = Label(win, text="ITS A TIE!!", font=('Arial', 18))
        text3.pack()

    elif str(e.get()).lower() == "rock":
        if computer == "paper":
            text4 = Label(win, text="The computer wins!, you lose", font=('Arial', 18))
            text4.pack()

        if computer == "scissors":
            text5 = Label(win, text="You win!, the computer lose", font=('Arial', 18))
            text5.pack()

    elif str(e.get()).lower() == "scissors":
        if computer == "rock":
            text6 = Label(win, text="The computer wins!, you lose", font=('Arial', 18))
            text6.pack()

        if computer == "paper":
            text7 = Label(win, text="You win!, the computer lose", font=('Arial', 18))
            text7.pack()

    elif str(e.get()).lower() == "paper":
        if computer == "scissors":
            text8 = Label(win, text="The computer wins!, you lose", font=('Arial', 18))
            text8.pack()

        if computer == "rock":
            text9 = Label(win, text="You win!, the computer lose", font=('Arial', 18))
            text9.pack()

    elif str(e.get()).lower() is not options:
        text10 = Label(win, text="There is no such thing as " + str(e.get()).lower() + " in this game. " + "Please enter the correct word", fg="red", font=('Arial', 18))
        text10.pack()

    text1 = Label(win, text=info, font=('Arial', 18))
    text1.pack()
    text2 = Label(win, text=info2, font=('Arial', 18))
    text2.pack()





lab = Label(win, text="Rock, Paper or Scissors?", font=('Arial', 18))
lab.pack()


e = Entry(win, borderwidth=10, bg="powderblue")
e.pack()


b = Button(win, text="Submit", font=('Arial', 18), bg="lightgreen", command=show)
b.pack()
win.mainloop()
Enter fullscreen mode Exit fullscreen mode

Discussion (0)