Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.26 KB | None | 0 0
  1. from tkinter import *
  2. >>> import random
  3. >>> def main():
  4.         class myGame:
  5.                 def __init__(self, parent):
  6.                         self.myParent = parent
  7.                         self.myLabel = Label(root)
  8.                         self.myLabel.configure(text = "Randy", bg ="white")
  9.                         self.mylabel.place(x=50,y=0)
  10.                         d
  11.                         self.compLabel = Label(root)
  12.                         self.compLabel.configure(text = "computer", bg = "white", fg = "red")
  13.                         self.compLabel.place(x=350,y=0)
  14.                         d
  15.                         self.playerLabel = Label(root)
  16.                         self.playerLabe1.configure(bg="white", height = "2", width = "15", font =24)
  17.                         self.resultLabel = Label(root)
  18.                         self.resultLabel.configure(bg = "white", height = "3", width = "25", font = 24)
  19.                         d
  20.                         self.button1 = Button(root, command=self.rock_and_comp)
  21.                         self.button1.configure(text = "Rock", bg = "white", borderwidth = "4")
  22.                         self.button1.place(x=0,y=100)
  23.                         d
  24.                         self.button2 = Button(root, command =self.paper_and_comp)
  25.                         self.button2.configure(text = "paper", bg = "White", borderwidth = "4")
  26.                         self.button2.place(x=50,y = 100)
  27.                         s
  28.                         self.button3 = button(root, command = self.scissors_and_comp)
  29.                         self.button3.configure(text = " Scissors", bg= "white" , borderwidth= "4")
  30.                         self.button3.place(x=50,y=100)
  31.                         d
  32.                         self.compButton1 = Button(root)
  33.                         self.compButton1.configure("rock", relief = "groove", borderwidth = "4", state = "disabled")
  34.                         self.compButton1.place(x=300, y=100)
  35.                         d
  36.                         self.compButton2 = Button(root)
  37.                         self.compButton2 = configure(text = "scissors", relief = "groove", borderwidth = "4", state = "disabled")
  38.                         self.compButton3.place(x=405,y=100)
  39.                         d
  40.                 def computerRandom(self):
  41.                         options = ["Rock", "Paper", "Scissors"]
  42.                         computer1 = random.choice(options)
  43.                         self.computer.set(options[random])
  44.                         return options[randomChoice]
  45.                 def game(self, selfComputer):
  46.                         if self.playerLabel==self.complabel:
  47.                                 self.resultLabel["text"] == "Draw!"
  48.                         elif self.playerLabel == "Rock" and self.compLabel == "paper":
  49.                                 return "Computer wins!"
  50.                         elif self.playerLabel == "paper" and self.complabel == "Scissor":
  51.                                 return "Computer Wins !"
  52.                         elif self.playerLabel == "scissors" and self.compLabel == "Rock":
  53.                                 return "Computer Wins !"
  54.                         elif self.playerLabel == "paper" and self.compLabel == "Rock":
  55.                                 return "player Wins !"
  56.                         elif self.playerLabel == "rock" and self.compLabel == "scissors":
  57.                                 return "player Wins !"
  58.                         elif self.playerLabel == "scissors" and self.compLabel == "paper":
  59.                                 return  "Player wins !"
  60.                         else:
  61.                                 return "Player wins!"
  62.                 def end(self):
  63.                         selfComputer = self.computerRandom()
  64.                         result = self.game(selfcomputer)
  65.                         if result == "Draw":
  66.                                 result.Label["text"] = "Draw!"
  67.                         elif result == "Computer wins!":
  68.                                 result.Label["text"] == "You lose!"
  69.                         else:
  70.                                 result.Label = "You Win !"
  71.         rook = Tk()
  72.         root.geometry("500x500+300+300")
  73.         roo.title("Rock, paper, scissors")
  74.         myapp = myGame(root)
  75.         root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement