"David Merrick" <merrick...@gmail.com> wrote
Others have answered the immediate issue.
But...

   def testNumber(self):
       guess = int(self.numberEnt.get())
       tries = 1

       while guess != the_number:
           if guess > the_number:
                     number += "Lower..."
           else:
                 number += "Higher..."
           guess = int(self.numberEnt.get())
           tries += 1

This is all wrong for a GUI appluication. You should not use loops in an event handler. Instead let the event loop in Tkinter do the looping. You respond to the user clicking the submit button and evaluate that single value. You then wait for the next button press to signal that there is a new value to check.

Any time you see a loop inside a GUI event handler you should stop and check that it belongs there.
Usually it doesn't!

number += "You guessed it!  The number was" + the_number
number += "And it only took you " + tries + " tries!\n"
self.numberTxt.delete(0.0, END)
self.numberTxt.insert(0.0, number)

It may just be mail but this appears to be outside the method definition and indeed outside the class. Is that correct? Or just a mail glitch? Since they refer to self they should be inside a method so I'll assume its a mail thing.

# main
number = ""
the_number = random.randint(1, 100)

If you are using classes its normal to put most of the variables inside the classes. There is no reason for the_number to be a global value, it would be better as part of the Application.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to