python calculator
<p>I am the newcomer and I found this calculator code in the web. </p>

<p>I want to add some function, like the pow() but it returns an error.</p>

<p>Please give me a tip!</p>

<p>The error:</p>

<blockquote>
  <p>button(powF, LEFT, 'pow', lambda w=display: w.set(w.pow()))</p>
  
  <p>AttributeError: StringVar instance has no attribute 'pow'</p>
</blockquote>

<hr>

<pre><code>from Tkinter import * 
import math

def frame(root, side):
   w = Frame(root)
   w.pack(side=side, expand=YES, fill=BOTH) 
   return w

def button(root, side, text, command=None):
   w = Button(root, text=text, command=command)
   w.pack(side=side, expand=YES, fill=BOTH)
   return w

class Calculator(Frame):
   def __init__(self):
       Frame.__init__(self)
       self.option_add('*Font', 'Verdana 20 bold') 
       self.pack(expand=YES, fill=BOTH)  
       self.master.title('tk') 
       self.master.iconname("calcu1ator") 

       display = StringVar()
     Entry(self,relief=SUNKEN,textvariable=display).pack(side=TOP,expand=YES,fill=BOTH)

       for key in ("123", "456", "789", "-0."):
           keyF = frame(self, TOP)

           for char in key:
               button(keyF, LEFT, char,lambda w=display, c=char: w.set(w.get() + c))

       opsF = frame(self, TOP)

       for char in "+-*/=":
           if char == '=':
               btn = button(opsF, LEFT, char)
               btn.bind('&lt;ButtonRelease-1&gt;',lambda e, s=self, w=display: s.calc(w), '+')
           else:
               btn = button(opsF, LEFT, char,lambda w=display, s=' %s '%char:w.set(w.get()+s))

       clearF = frame(self, BOTTOM)
       button(clearF, LEFT, 'Clr', lambda w=display: w.set(''))

       #powF = frame(self, BOTTOM)
       #button(powF, LEFT, 'pow', lambda w=display: pow(w,2))

   def calc(self, display):
       try:
           display.set(eval(display.get()))
       except:
           display.set("ERROR")

if __name__ == '__main__':
   Calculator().mainloop() 
</code></pre>
