Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add files via upload
  • Loading branch information
SinghalChinmay authored Oct 14, 2021
commit e2cdd875ba5f59ee360d1c5d26ff3ff291904538
72 changes: 72 additions & 0 deletions GUIScripts/Rock Paper Scissors/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import random
from tkinter import Tk, Button, END, Entry, mainloop, DISABLED, NORMAL
from PIL import Image, ImageTk

root = Tk()
root.title('Rock Paper Scissors')
root.geometry("675x250")
root.config(bg='#83b576')

#results
def Rock():
answer["state"] = NORMAL
answer.delete(0, END)
computer = random.choice(['r', 'p', 's'])
if computer == 'r':
answer.insert(0,f"Draw, you both chose 'rock' ")
elif computer == 'p':
answer.insert(0,f"You lost, computer chose 'paper' defeating you")
else:
answer.insert(0,f"You won!!, computer chose 'scissors' losing to you")
answer["state"] = DISABLED

def Scissors():
answer["state"] = NORMAL
answer.delete(0, END)
computer = random.choice(['r', 'p', 's'])
if computer == 's':
answer.insert(0,f"Draw, you both chose 'scissors'")
elif computer == 'r':
answer.insert(0,f"You lost, computer chose 'rock' defeating you")
else:
answer.insert(0,f"You won!!, computer chose 'paper' losing to you")
answer["state"] = DISABLED

def Paper():
answer["state"] = NORMAL
answer.delete(0, END)
computer = random.choice(['r', 'p', 's'])
if computer == 'p':
answer.insert(0,f"Draw, you both chose 'paper'")
elif computer == 's':
answer.insert(0,f"You lost, computer chose 'scissors' defeating you")
else:
answer.insert(0,f"You won!!, computer chose 'rock' losing to you")
answer["state"] = DISABLED

#buttons
Rock_btn = ImageTk.PhotoImage(Image.open('Images/Rock.jpg'))
Scissors_btn = ImageTk.PhotoImage(Image.open('Images/Scissors.jpg'))
Paper_btn = ImageTk.PhotoImage(Image.open('Images/Paper.jpg'))


Rock_butn = Button(root, image=Rock_btn, command=Rock)
Rock_butn.place(x=75, y=30 )

Paper_butn = Button(root, image=Paper_btn, command = Paper)
Paper_butn.place(x=300, y=25 )

Scissors_butn = Button(root, image=Scissors_btn, command = Scissors)
Scissors_butn.place(x=550, y=25 )


answer = Entry(
root,
width=50,
font=('Courier New', 14),
state = DISABLED
)

answer.place(y=200, x=80)

mainloop()