<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> 
<HEAD> 
<TITLE>Converted from Rich Text</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"><META NAME="generator" CONTENT="rt2html converter">
</HEAD> 
<BODY BGCOLOR="#ffffff" TEXT="#000000">
<DIV ALIGN=LEFT>Some comments, short (typing on mobiles is no fun):</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>* self.guess gets overridden after the first iteration with an integer. guess what, integer don't have get methods.</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>* I'd suggest to use if/elif/else, not independant ifs. better to read anyway.</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>* consider using a dictionary to parametrize your levels:</DIV> 
<DIV ALIGN=LEFT>  guess_conf = dict(easy=3, medium=6, difficult=9)</DIV> 
<DIV ALIGN=LEFT>  level="easy"</DIV> 
<DIV ALIGN=LEFT>  guesses = guesses_conf[level]</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>all 100% genuine untested tips</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>Andreas</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>_____ Ursprüngliche Mitteilung _____</DIV> 
<DIV ALIGN=LEFT>Betreff: [Tutor] Help python coding not working</DIV> 
<DIV ALIGN=LEFT>Autor: "super krital" &lt;super_krital_000@hotmail.com&gt;</DIV> 
<DIV ALIGN=LEFT>Datum:  8. Mai 2007 8:7:33</DIV> 
<DIV ALIGN=LEFT>&nbsp;</DIV><DIV ALIGN=LEFT>Hi need to get this program running for school so my teacher said to use the <BR>forum etc. Its working fine except its not comparing my guess with the <BR>result. im only having trouble with the second half or def update_text_count <BR>can you please help find a solution so my program works please. i dont see <BR>why it is not.<BR><BR>#Krital<BR>#Guess my number game assignment<BR><BR>from Tkinter import *</DIV> 
<DIV ALIGN=LEFT>import random<BR><BR><BR>class Application(Frame):<BR>    """GUI Application for game difficulty."""<BR>    def __init__(self,master):<BR>        """initialise frame."""<BR>        Frame.__init__(self,master)<BR>        self.grid()<BR>        self.bttn3_clicks=0</DIV> 
<DIV ALIGN=LEFT>        self.create_widgets()<BR><BR>    #Creating user instruction labels<BR><BR>    def create_widgets(self):<BR>        #create widgets for difficulty levels<BR>        #create description label<BR>        Label(self,<BR>              text="Choose your difficalty level"<BR>              ).grid(row=0,column=0,sticky=W)</DIV> 
<DIV ALIGN=LEFT><BR>        Label(self,<BR>              text="Select one:"<BR>              ).grid(row=1,column=0,sticky=W)<BR><BR><BR>#Since only one radio button can be selected, they share one special object <BR>that<BR>#reflects which of the radio buttons is selected. This object needs to be an <BR>instance of the</DIV> 
<DIV ALIGN=LEFT>#StringVar class frpm the Tkinter module, which allows a string to be stored <BR>and retrieved.<BR><BR>        #create a variable for game difficulty<BR>        self.difficulty = StringVar()<BR><BR>        #Create the Easy radio button<BR>        Radiobutton(self,<BR>                    text="Easy",<BR>                    variable=self.difficulty,</DIV> 
<DIV ALIGN=LEFT>                    value="easy",<BR>                    command=self.random_number<BR>                    ).grid(row=2, column=0, sticky=W)<BR><BR><BR>        Radiobutton(self,<BR>                    text="Medium",<BR>                    variable=self.difficulty,<BR>                    value="medium",<BR>                    command=self.random_number</DIV> 
<DIV ALIGN=LEFT>                    ).grid(row=3, column=0, sticky=W)<BR><BR>        Radiobutton(self,<BR>                    text="Hard",<BR>                    variable=self.difficulty,<BR>                    value="hard",<BR>                    command=self.random_number<BR>                    ).grid(row=4, column=0, sticky=W)<BR><BR>        self.bttn = Button(self)</DIV> 
<DIV ALIGN=LEFT>        self.bttn["text"]="Exit"<BR>        self.bttn["command"]=self.stop<BR>        self.bttn.grid(row=23,column=1,sticky=W)<BR><BR>        self.bttn2 = Button(self)<BR>        self.bttn2["text"]="Reset"<BR>        self.bttn2["command"]=self.reset<BR>        self.bttn2.grid(row=23,column=0,sticky=W)<BR><BR>        #using the Grid layout manager to be specific about the labels </DIV> 
<DIV ALIGN=LEFT>placement<BR>        self.inst_lbl=Label(self,text="Please guess a number.")<BR>        self.inst_lbl.grid(row=6,column=0,columnspan=2, sticky=W)<BR>        #Sticky W means the label is forced to the west-or is left <BR>justified!<BR>        #sticky can be N,S,E or W<BR><BR>        #creating an entry widget to make a guess<BR>        self.guess=Entry(self)<BR>        self.guess.grid(row=7,column=0,sticky=W)</DIV> 
<DIV ALIGN=LEFT>        #self.guess.focus_set()<BR><BR>        self.bttn3=Button(self,text="Total <BR>Goes=0",relief=FLAT,command=self.update_text_count)<BR>        self.bttn3.grid(row=8,column=0, sticky=W)<BR><BR>  #create a button to enter the guess<BR><BR>        self.enter_bttn=Button(self)<BR>        self.enter_bttn["text"]="Enter"</DIV> 
<DIV ALIGN=LEFT>        self.enter_bttn["command"]=self.update_text_count<BR>        self.enter_bttn.grid(row=7,column=1,sticky=W)<BR><BR><BR>        #Createing the text box to display the user's selection<BR>        self.message_txt=Text(self,width=40,height=5,wrap=WORD)<BR>        self.message_txt.grid(row=11,column=0, columnspan=3)<BR><BR><BR>    def random_number(self):    #creating a definition for all the random </DIV> 
<DIV ALIGN=LEFT>numbers to be generated in<BR>        difficulty=self.difficulty.get()<BR>        if difficulty=="easy":<BR>            self.number = random.randrange(10)+1<BR>        elif difficulty=="medium":<BR>            self.number = random.randrange(50)+1<BR>        else:<BR>            self.number = random.randrange(100)+1<BR><BR>    def update_text_count(self):</DIV> 
<DIV ALIGN=LEFT>        #Update counter and maximum user guesses<BR>        self.bttn3_clicks+=1<BR>        self.bttn3["text"]="Total Goes= "+str(self.bttn3_clicks)<BR>        difficulty=self.difficulty.get()<BR>        if difficulty=="easy":<BR>            if self.bttn3_clicks &gt; 3:<BR>                message="You have run out of guesses. The number you wanted <BR>was ", self.number<BR>        if difficulty=="medium":<BR>            if self.bttn3_clicks &gt; 6:</DIV> 
<DIV ALIGN=LEFT>                message="You have run out of guesses. The number you wanted <BR>was ", self.number<BR>        if difficulty=="hard":<BR>            if self.bttn3_clicks &gt; 9:<BR>                message="You have run out of guesses. The number you wanted <BR>was ", self.number<BR><BR>        #Update text area and display user's game difficulty<BR>        self.guess = int(self.guess.get())#Having trouble on this line!!!<BR></DIV> 
<DIV ALIGN=LEFT>        if self.guess&gt;self.number:<BR>            message=str(self.guess)+" is too High.Guess again"<BR>        if self.guess&lt;self.number:<BR>            message=str(self.guess)+" is too low. Guess again"<BR><BR>        if self.guess==self.number:<BR>            message=str(self.guess)+" is correct!",<BR>            "goes= ",self.bttn3_clicks<BR><BR>    #deleting any text in the text box and inserting the string just created </DIV> 
<DIV ALIGN=LEFT>as well as disabling the box<BR>        self.message_txt.config(state=NORMAL)<BR>        self.message_txt.delete(0.0, END)<BR>        self.message_txt.insert(0.0, message)<BR>        self.message_txt.config(state=DISABLED)<BR><BR>    def reset(self):    #creating definition to reset the game<BR>        number=0<BR>        self.bttn3_clicks=0<BR>        self.create_widgets()</DIV> 
<DIV ALIGN=LEFT><BR>    def stop(self):<BR>        root.destroy()<BR><BR>        #wrap the program<BR><BR>root=Tk()<BR>root.title("~*Guess the Number Game*~")<BR>root.geometry("500x400")<BR></DIV> 
<DIV ALIGN=LEFT>app=Application(root)<BR><BR>root.mainloop()<BR><BR>_________________________________________________________________<BR>Advertisement: Senior Management roles paying $80k+ Search now at <BR>www.seek.com.au <BR>http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eexecutive%2Eseek%2Ecom%2Eau%2F%3Ftracking%3Dsk%3Ahet%3Ase%3Anine%3A0%3Ahot%3Atext&amp;_t=763838044&amp;_r=seek_may07_snrmanagement&amp;_m=EXT<BR><BR>_______________________________________________</DIV> 
<DIV ALIGN=LEFT>Tutor maillist  -  Tutor@python.org<BR>http://mail.python.org/mailman/listinfo/tutor<BR></DIV> 
</BODY>
</HTML>