Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91067 > unrolled thread

Re: need help with an accessibility prototype

Started byLaura Creighton <lac@openend.se>
First post2015-05-22 21:50 +0200
Last post2015-05-22 21:50 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: need help with an accessibility prototype Laura Creighton <lac@openend.se> - 2015-05-22 21:50 +0200

#91067 — Re: need help with an accessibility prototype

FromLaura Creighton <lac@openend.se>
Date2015-05-22 21:50 +0200
SubjectRe: need help with an accessibility prototype
Message-ID<mailman.237.1432324217.17265.python-list@python.org>
In a message of Fri, 22 May 2015 12:29:20 -0400, "Eric S. Johansson" writes:
>2 needs.  first is determining if NaturallySpeaking injects keycodes or 
>ascii char into the windows input queue.  second is building a test 
>widget to capture and display text.
>
>I think I can solve both of these by building a simple text widget 
>(tkinter? qt? ??) to capture keycodes.  problem, is in <mumble><mumble> 
>yrs of programming, I've never written a GUI interface so I have no idea 
>where to start.  help, tutor, pointers to samples would be most welcome.
>
>--- eric

The best online manual I know of for Tkinter is here:
http://effbot.org/tkinterbook/ despite being 10 years old.  But then I
haven't looked for one for about that long, either.

For tkinter key events are a  bit odd, given that Tkinter tries to
help you and considers special keys, punctuation and non-ascii printing
characters as separate things should you want to bind to them.

It's actually easier to write the code and say 'play with this' rather
than to explain when you would need to use event.char and when event.keysym
(Plus the code will tell you what Tkinter uses, I might remember wrong.)

Save this in a file and run it.

from Tkinter import *
root = Tk()
prompt = 'Press any key.  Remember to keep your mouse in the cyan box. '
lab = Label(root, text=prompt, width=len(prompt), bg='cyan')
lab.pack()

def key(event):
    msg = 'event.char is %r and event.keysym is %r' % (event.char, event.keysym)
        lab.config(text=msg)

root.bind_all('<Key>', key)
root.mainloop()

----------
If you need to put unicode chars in your label, that's a different probem.
If knowing when a control or alt-gr key is released is important to you,
the code will have to be modified to detect this specially.  Type some
control chars at the cyan window and you will see what I mean.

Happy Hacking,
Laura

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web