self hist append(coderesult none return result try stmtnone def gethist(self)return '\njoin(self histdef getcalcargs()from sys import argv get cmdline args in dict config {ex-bg black -fg red for arg in argv[ :]font not yet supported if arg in ['-bg''-fg']-bg red-{'bg':'red'tryconfig[arg[ :]argv[argv index(arg exceptpass return config if __name__ ='__main__'calcgui(**getcalcargs()mainloop(in default toplevel window using pycalc as component pycalc serves standalone program on my desktopbut it' also useful in the context of other guis like most of the gui classes in this bookpycalc can be customized with subclass extensions or embedded in larger gui with attachments the module in example - demonstrates one way to reuse pycalc' calcgui class by extending and embeddingsimilar to what was done for the simple calculator earlier example - pp \lang\calculator\calculator_test py ""test calculatoruse as an extended and embedded gui component ""from tkinter import from calculator import calcgui def calccontainer(parent=none)frm frame(parentfrm pack(expand=yesfill=bothlabel(frmtext='calc container'pack(side=topcalcgui(frmlabel(frmtext='calc container'pack(side=bottomreturn frm class calcsubclass(calcgui)def makewidgets(selffgbgfont)label(selftext='calc subclass'pack(side=toplabel(selftext='calc subclass'pack(side=bottomcalcgui makewidgets(selffgbgfont#label(selftext='calc subclass'pack(side=bottompycalca calculator program/object