http://www.perlmonks.org?node_id=330430


in reply to Simple Calculator using Tk

A neat little job ++! Also a good choice of application for GUI practice with lots of scope for growth (consider adding a 'paper tape' feature, or date calculations for instance).

One minor thing (which bites me often too) - the generation of a bug via cut & paste. You duplicated the line to create all your menu commands, and consequently your Exit command is passed as a 'Q' button press. Unfortunately there is no 'Q' button, so the 'Q' is passed on to calc(), where it acts to clear the display and buffer.

Update: To clarify, there is nothing fundamentally wrong with cut & paste code generation, as long as you are aware of and checking carefully for this type of error. However, if you find yourself needing many copies of the same line with very minor changes, sometimes it indicates that you should consider a different structure.

--
I'd like to be able to assign to an luser

Replies are listed 'Best First'.
Re: Re: Simple Calculator using Tk
by eoin (Monk) on Feb 20, 2004 at 13:08 UTC
    Damn, I should have spoted that 'Q' typo. The 'Q' should be passed as a key press instead of a button press. I'll update the code correcting that.

    Regarding the cut and paste aspect. I didn;t really think about doing it any other way. I suppose I could have now that you say it, but this is the quickest and easiest(although not always the right, as you pointed out) way to do this.

    Cheers, Eoin...