It's a calculator.
can do +-*/
fromTkinterImport* fromTkinterImportTTKdefcallback (num): Furm= Display.get () +num display.set (Furm)defcalculate ():Try: Furm=Display.get () Res=eval (Furm) display.set (Furm+"="+Str (res))except: Display.set ("Please clear it!")defClear (): Display.set ("") Root=Tk () frame=Frame (Root) root.title ("Calculator") Display=stringvar () lbl= Label (Root, relief="Sunken", Borderwidth=3, anchor=SE) lbl.configure (Background=" White", height=2, width=25) lbl['textvariable'] =Displaylbl.grid (Row=0, Column=0, columnspan=4, sticky=SE) Lbl.bind ('<Button-1>', Display.set ("') ) TTK. Button (root, Text="7", Width=5, command=Lambda: Callback ("7"). Grid (Row=3, column=0) TTK. Button (root, Text="8", Width=5, command=Lambda: Callback ("8"). Grid (Row=3, Column=1) TTK. Button (root, Text="9", Width=5, command=Lambda: Callback ("9"). Grid (Row=3, column=2) TTK. Button (root, Text="+", Width=5, command=Lambda: Callback ("+"). Grid (Row=3, column=3) TTK. Button (root, Text="4", Width=5, command=Lambda: Callback ("4"). Grid (Row=4, column=0) TTK. Button (root, Text="5", Width=5, command=Lambda: Callback ("5"). Grid (Row=4, Column=1) TTK. Button (root, Text="6", Width=5, command=Lambda: Callback ("6"). Grid (Row=4, column=2) TTK. Button (root, Text="-", Width=5, command=Lambda: Callback ("-"). Grid (Row=4, column=3) TTK. Button (root, Text="1", Width=5, command=Lambda: Callback ("1"). Grid (Row=5, column=0) TTK. Button (root, Text="2", Width=5, command=Lambda: Callback ("2"). Grid (Row=5, Column=1) TTK. Button (root, Text="3", Width=5, command=Lambda: Callback ("3"). Grid (Row=5, column=2) TTK. Button (root, Text="*", Width=5, command=Lambda: Callback ("*"). Grid (Row=5, column=3) TTK. Button (root, Text="0", Width=5, command=Lambda: Callback ("0"). Grid (Row=6, column=0) TTK. Button (root, Text=".", Width=5, command=Lambda: Callback ("."). Grid (Row=6, Column=1) TTK. Button (root, Text="%", Width=5, command=Lambda: Callback ("%"). Grid (Row=6, column=2) TTK. Button (root, Text="/", Width=5, command=Lambda: Callback ("/"). Grid (Row=6, column=3) TTK. Button (root, Text="Clear", width=5,command=Lambda: Clear ()). Grid (Row=7, column=2, columnspan=1) TTK. Button (root, Text="=", width=5,command=Lambda: Calculate ()). Grid (Row=7, column=3, columnspan=1) root.resizable (0, 0) root.mainloop ()
Very powerful interface.
Multiple operations can be performed
You see, the priority is still right.
It's so willful.
Python-Implemented small key calculator