[Tkinter-discuss] Making a keyboard
klappnase at web.de
Thu Jan 18 10:38:54 CET 2007
On Wed, 17 Jan 2007 16:48:02 -0700
Bob Greschke <bob at passcal.nmt.edu> wrote:
> I'm making a popup keyboard for some touchscreen input.
> I have, for example, got:
> Button(KBFrm, text = "1", command = Command(kbhit, "1")...
> def kbhit(K, e = None):
> The letter keys work OK, but in the number keys 1 through 5 don't
> seem to do anything, but 6-9 and 0 work. Looking at e.keysym and
> e.keysym_num in a whole other routine says that the 1 key on a
> keyboard generates 1, and 49, so I don't get what is going on. Are
> <1> through <5> some kind of shortcuts for mouse button stuff?
In fact, <1> is a synonym for <ButtonPress-1>, so you better be explicit
and use <KeyPress-...> events.
> Also, is there something like a dictionary in the system where I can
> get the keysym for the punctuation keys like
> KeySyms["$"] = "dollar"
> or do I have to make one myself?
Maybe you can use a test script to find them out:
>>> from Tkinter import *
>>> def test(ev):
... print ev.keysym
>>> c.bind('<1>', lambda eveent:c.focus_set())
>>> c.bind('<Any-Key>', test)
# some keystrokes:
I am not sure if the keys that use modifiers are relieable when used on different systems.
I hope this helps
More information about the Tkinter-discuss