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

Alan Gauld alan.gauld at btinternet.com
Mon Sep 26 10:03:43 CEST 2011


On 26/09/11 03:25, brandon w wrote:
> This code calculates money. The problem is that in the first field after
> the mouse enters a second time updates itself with the value from the
> last field. I don't want it to do that.
> I think that the problem is in the "callback" method.
>

I haven't gone through this in depth but one thing that
looked odd to me was:


> def calculateAmount():
>      field1 = varText.get()
> ...
>      field2 = varText.get()
> ...
>      field3 = varText.get()
> ...
>      field4 = varText.get()
> ...
>      field5 = varText.get()

Are all fields supposed to be getting the same value?
And if so why not just do it once at the start of the function?

But as I say I didn't read it all in depth so maybe you
have some magic going on that changes the value between reads...

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



More information about the Tutor mailing list