self help(def onhist(self)show recent calcs log popup from tkinter scrolledtext import scrolledtext new toplevel(ok button(newtext="ok"command=new destroyok pack(pady= side=bottomtext scrolledtext(newbg='beige'text insert(' 'self eval gethist()text see(endtext pack(expand=yesfill=bothor pp gui tour make new window pack first=clip last add text scrollbar get evaluator text scroll to end new window goes away on ok press or enter key new title("pycalc history"new bind(""(lambda eventnew destroy())ok focus_set(make new window modalnew grab_set(get keyboard focusgrab app new wait_window(don' return till new destroy def help(self)self infobox('pycalc''pycalc +\ ' python/tkinter calculator\ 'programming python \ 'may \ '( )\ \ 'use mouse or keyboard to\ 'input numbers and operators,\ 'or type code in cmd popup'###############################################################################the expression evaluator class embedded in and used by calcgui instanceto perform calculations ###############################################################################class evaluatordef __init__(self)self names {self opndself optr [][self hist [self runstring("from math import *"self runstring("from random import *"def clear(self)self opndself optr [][if len(self hist self hist ['clear'elseself hist append('--clear--'def popopnd(self)value self opnd[- self opnd[- :[ names-space for my vars two empty stacks my prev calcs history log preimport math modules into calc' namespace leave names intact don' let hist get too big pop/return top|last opnd to display and shift next pycalca calculator program/object