Tkinter, add pressed buttons onto string display string, how to?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Apr 5 17:17:50 EDT 2008


On Sat, 05 Apr 2008 13:17:45 -0700, skanemupp wrote:

>> input = "hello"
>> input += " world"
>> print input
> 
> this i know. im wondering how to handle the variable in the actual
> program. this exception i get:
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__
>     return self.func(*args)
>   File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py",
> line 48, in <lambda>
>     self.btnDisplay = Button(self,text='+',command=lambda
> n="+":self.Display(n),width=1,height=1)
>   File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py",
> line 92, in Display
>     str = number + str
> UnboundLocalError: local variable 'str' referenced before assignment

Just like the message says: You are trying to use `str` (on the right hand
side of the assignment) before anything is bound to that name.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list