[Tutor] (no subject)
Nick Treloar
treloary_27 at hotmail.com
Fri Jun 22 09:13:52 CEST 2007
im not sure why this progrm isnt running properly one of the button wont
open and it teel me a computer_guess is not defined here is my code
#NiCk TrEloaR PrOgRaMiNg Co.
#scissors paper rock
#10/6/07
from Tkinter import*
from random import choice
class Application(Frame):
def __init__(self,master):
"""Initalize Frame."""
Frame.__init__(self,master)
self.grid()
self.create_widget()
self.computer_guess()
#creating user indstructions
def create_widget(self):
#create description label
Label(self,
text="scissors paper rock "
).grid(row = 0,column = 0,sticky = W)
#create the exit button
self.exit_bttn = Button(self, text = "Exit", font = ("Arial", 12,
"bold"), command = self.quit)
self.exit_bttn.grid(row = 30, column = 0, sticky = E)
#create the rock button
self.rock_bttn = Button(self, text = "rock", font = ("Arial", 12,
"bold"), command = self.rock)
self.rock_bttn.grid(row = 1, column = 1, sticky = W)
#create the scissors button
self.scissors_bttn = Button(self, text = "scissors", font =
("Arial", 12, "bold"), command = self.scissors)
self.scissors_bttn.grid(row = 2, column = 2, sticky = W)
#create the paper button
self.paper_bttn = Button(self, text = "paper", font = ("Arial", 12,
"bold"), command = self.paper)
self.paper_bttn.grid(row = 3, column = 3, sticky = W)
def rock(self):
value = "rock"
computer_guess == random.choice(["scissors", "paper", "rock"])
if computer_guess == "rock":
Label(self,
text = "this is a draw!!", fg = "blue", font = ("Arial",
14, "bold"),
).grid(row = 9, column = 0, sticky = W)
elif computer_guess == "paper":
Label(self,
text = "you lose paper smothers rock", fg = "blue", font =
("Arial", 14, "bold"),
).grid(row = 9, column = 0, sticky = W)
else:
Label(self,
text = "you win rock smashes scissors", fg = "blue", font
= ("Arial", 14, "bold"),
).grid(row = 9, column = 0, sticky = W)
def scissors(self):
value = "scissors"
computer_guess == random.choice(["scissors", "paper", "rock"])
if computer_guess == "rock":
Label(self,
text = "computer wins rock smashes scissors", fg = "blue",
font = ("Arial", 14, "bold"),
).grid(row = 9, column = 0, sticky = W)
elif computer_guess == "paper":
Label(self,
text = "you win rock smaches scissors", fg = "blue", font
= ("Arial", 14, "bold"),
).grid(row = 9, column = 0, sticky = W)
else:
Label(self,
text = "this is a draw", fg = "blue", font = ("Arial", 14,
"bold"),
).grid(row = 9, column = 0, sticky = W)
def paper(self):
value = "paper"
computer_guess == random.choice(["scissors", "paper", "rock"])
if computer_guess == "rock":
Label(self,
text = "yau win paper smothers rock", fg = "blue", font =
("Arial", 14, "bold"),
).grid(row = 9, column = 0, sticky = W)
elif computer_guess == "paper":
Label(self,
text = "this is a draw", fg = "blue", font = ("Arial", 14,
"bold"),
).grid(row = 9, column = 0, sticky = W)
else:
Label(self,
text = "computer wins scissors cut paper", fg = "blue",
font = ("Arial", 14, "bold"),
).grid(row = 9, column = 0, sticky = W)
root=Tk()
root.title("scissors paper rock")
root.geometry("600x600")
app = Application(root)
_________________________________________________________________
Advertisement: Ministry of Sound's Sessions 4 has arrived. Have a listen!
http://ninemsn.com.au/share/redir/adTrack.asp?mode=click&clientID=788&referral=hotmailtagline&URL=http://music.ninemsn.com.au/playlist.aspx?sectionid=2465§ionname=artistfeature&subsectionid=9961&subsectionname=sessions4&categoryid=2602
More information about the Tutor
mailing list