Remplacer un appui touche par un autre
Salut,
J'ai un petit problème récurent, je ne sais pas exploiter les évènements clavier, et ce n'est pas faute d'avoir potassé les docs. En l'occurrence, quand on presse la touche return, j'aimerai bien qu'on aille au champ suivant, donc remplacer l'évènement 'touche return appuyée" par "touche tablulation appuyée". Si quelqu'un sait, je pense que ça me servira de déclic pour toute cette partie des évènements qui me semble obscure.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| from Tkinter import *
class myEntry(Entry):
def __init__(self, container, **kwds):
Entry.__init__(self, container, **kwds)
self.bind("<Key-Return>", self.returnPressed)
def returnPressed(self, event):
print "return pressed"
# TODO: here tabulation
root = Tk()
for counter in range(20):
temp_var = StringVar()
temp_var.set("var #%u"%(counter + 1))
myEntry(root, textvariable=temp_var).grid()
root.mainloop() |
A+
Pfeuh