of coursereal calculators don' usually work by building up expression strings and evaluating them all at oncethat approach is really little more than glorified python command line traditionallyexpressions are evaluated in piecemeal fashion as they are enteredand temporary results are displayed as soon as they are computed implementing this behavior requires bit more workexpressions must be evaluated manually and in partsinstead of calling the eval function only once but the end result is much more useful and intuitive lesson reusability is power though simpleattaching and subclassing the calculator graphicallyas shown in figure - illustrates the power of python as tool for writing reusable software by coding programs with modules and classescomponents written in isolation almost automatically become general-purpose tools python' program organization features promote reusable code in factcode reuse is one of python' major strengths and has been one of the main themes of this book good object-oriented design takes some practice and forethoughtand the benefits of code reuse aren' apparent immediately and sometimes we have good cause to be more interested in quick fix rather than future use for the code but coding with some reusability in mind can save development time in the long run for instancethe handcoded custom parsers shared scannerthe calculator gui uses the widgets module from we discussed earlierand the next section will reuse the guimixin class from as well sometimes we're able to finish part of job before we start this section presents the implementation of pycalca more realistic python/tkinter program that implements such traditional calculator gui it touches on the subject of text and languages in two waysit parses and evaluates expressionsand it implements kind of stack-based language to perform the evaluation although its evaluation logic is more complex than the simpler calculator shown earlierit demonstrates advanced programming techniques and serves as an interesting finale for this running pycalc as usuallet' look at the gui before the code you can run pycalc from the pygadgets and pydemos launcher bars at the top of the examples treeor by directly running the file calculator py listed shortly ( click it in file exploreror type it in shell command linefigure - shows pycalc' main window by defaultit shows operand buttons in black-on-blue (and opposite for operator buttons)but font and color options can be passed into the gui class' constructor method of coursethat means gray-on-gray in this bookso you'll have to run pycalc yourself to see what mean pycalca calculator program/object