[Tutor] My code works but it is a little bit broken.

Alan Gauld alan.gauld at btinternet.com
Tue Sep 27 12:43:09 CEST 2011


On 27/09/11 02:32, brandon w wrote:
> The fields take the initial value and multiply it to get the amount.
> The problem in in the callback function. It uses the <Enter> event to
> clear a field, but when the mouse enters a second time it adds a numeric
> value. This is a semantic error. It is not doing what I want it to do.

Here is the callback function:

def callback(event):
     field0 = varText1.get()
     initAmount.delete(0, END)
     initAmount.insert(0, field0)
     return

It quite clearly does an insert. If you don't want the insert remove it?
I still don't think I understand what your problem is? You read the 
field and insert it, presumably you did that for a reason, so why are 
you surprised when it works as you designed it to work?


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



More information about the Tutor mailing list