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

brandon w bbbgggwww at gmail.com
Tue Sep 27 03:32:48 CEST 2011


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.

On Mon, Sep 26, 2011 at 4:03 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> 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/
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110926/fc607289/attachment-0001.html>


More information about the Tutor mailing list