Hi,
was wondering whether you can help?
Say I got a dictionary of keys:values
:
And what I want to do is depending on what
key (a,b,c) the person presses, I want to output the value (tom, dic,
harry).
So I program like this:
import Tkinter
D={a:"tom", b:"dick", c:"harry"}
text.bind('<Key>', self.Conv)
def Conv(self,event):
if
D.has_key(event.keysym):
str="The name
is"+str
self.text.insert(END,str)
return 'break'
(If I had to do each one (i.e. without the
dictionary) I would do as follows:
def Conv(self,event):
if event.keysym==a:
str="tom"
self.text(END, str)
return 'break'
)
There is clearly a mistake in the
first function, only thing is I cannot spot it and thus the thing does not
work.
Any ideas?
Igor
|
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor