elsetext set(''excepttext set("error"bad as statement tooworked as statement other eval expression errors if __name__ ='__main__'calcgui(mainloop(figure - the calc script in action on windows (result= building the gui nowthis is about as simple as calculator can bebut it demonstrates the basics this window comes up with buttons for entry of numbersvariable namesand operators it is built by attaching buttons to frameseach row of buttons is nested frameand the gui itself is frame subclass with an attached entry and six embedded row frames (grids would work heretoothe calculator' frameentry fieldand buttons are made expandable in the imported widgets utility module we coded earlier in example - this calculator builds up string to pass to the python interpreter all at once on "evalbutton presses because you can type any python expression or statement in the entry fieldthe buttons are really just convenience in factthe entry field isn' much more than command line try typing import sysand then dir(systo display sys module attributes in the input field at the top--it' not what you normally do with calculatorbut it is demonstrative nevertheless once againi need to warn you about running code strings like this if you can' be sure they won' cause damage if these strings can be entered by users you cannot trustthey will have access to anything on the computer that the python process has access to see and for more on security issues related to code run in guiweband other contexts pycalca calculator program/object