Advertisement
Guest User

Untitled

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