[Tutor] Help me.. problem in building calculator application

Kent Johnson kent37 at tds.net
Thu Oct 26 15:21:47 CEST 2006


Asrarahmed Kadri wrote:
>  
>  
> Hi folks,
>  
> I am trying to build a rudimentary calculator application using Tkinter...
>  
> I have used one Entry widget for displaying the input and output data.
> All this is put in a class.
> The porblem is when I click teh '+' button, teh callback function is 
> called but it gives me an error message: AttributeError: 'str' object 
> has no attribute 'get'
>  
> I have defined a variable, self.str1 = StringVar() to bind it with the 
> entry widget and I am calling the function when + is clciked. The 
> function is as follows:
>  
>    self.buttonPlu = Button(self.container3,text='+',command = lambda: 
> self.oprClick('+',*self.str1.get()))*
>  
> Can't we use the get() method to access the contents of the entry 
> widget. Is there any other way to access the contents of the entry 
> widget....???

The error message is saying that the object you are calling get() on is 
a string, not a StringVar. Please post complete code and the complete 
error message including traceback.

Kent



More information about the Tutor mailing list