Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92043
| From | Laura Creighton <lac@openend.se> |
|---|---|
| Subject | Re: Keypress Input |
| References | <rBHbx.75089$MO7.40532@fx10.iad><201506031859.t53Ix49H007428@fido.openend.se> |
| Date | 2015-06-04 12:50 +0200 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.156.1433415061.13271.python-list@python.org> (permalink) |
In a message of Wed, 03 Jun 2015 20:59:04 +0200, Laura Creighton writes:
>Tkinter runs on raspberry pi.
>
>Get it installed, and then run this program.
>
>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()
>
>Now you will have to bind the various keys to do what it is you want.
>You need to read online dociumentation for tkinter to learn how to do
>this, as well as how to use tkinter in general.
>
>Laura
I was in a hurry last night. What I mean is -- Python out of the box
is not in the business of detecting key input. You normally use a
Gui kit for that. There are lots of them, and they all do things
sort of the same but slightly differently. So what you need is
a gui kit that runs on Raspberry Pi. If you are already using a
gui, then it probably will do it for you; check its documentation.
However, if you aren't using one ...
I don't have a Raspberry Pi, but I have read that tkinter runs there.
We can check. First make sure that tkinter is installed and run that
short program I posted (also included above). If it works -- every time
you press a key char, it is supposed to tell you what you typed -- then
you are in business. I just bound pressing every key with telling you that
it got pressed. You will need to bind particular keys to do particular
things, which you can read about in tkinter documentation about keybinding.
Tkinter is python wrapped around tk, so this page
http://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm
lists all the keys you can bind. Not every OS provides the ability to
bind every key. You are advised to try the keys you want to bind with
Raspberry Pi -- not having one I cannot check this for you.
Laura
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-03 18:22 +0000
Re: Keypress Input Laura Creighton <lac@openend.se> - 2015-06-03 20:59 +0200
Re: Keypress Input Gary Herron <gherron@digipen.edu> - 2015-06-03 12:15 -0700
Re: Keypress Input Gary Herron <gherron@digipen.edu> - 2015-06-03 11:47 -0700
Re: Keypress Input Laura Creighton <lac@openend.se> - 2015-06-04 12:50 +0200
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-06 18:28 +0000
Re: Keypress Input Laura Creighton <lac@openend.se> - 2015-06-06 22:52 +0200
Re: Keypress Input Chris Angelico <rosuav@gmail.com> - 2015-06-07 07:20 +1000
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-06-06 22:31 -0600
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-15 05:15 +0000
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-16 15:09 +0000
Re: Keypress Input Christian Gollwitzer <auriocus@gmx.de> - 2015-06-19 07:20 +0200
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-20 14:59 +0000
Re: Keypress Input Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-15 18:03 -0700
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-07-15 22:30 -0600
Re: Keypress Input Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-16 10:22 -0700
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-07-16 15:27 -0600
Re: Keypress Input Terry Reedy <tjreedy@udel.edu> - 2015-07-16 02:08 -0400
Re: Keypress Input Rick Johnson <rantingrickjohnson@gmail.com> - 2015-07-16 11:30 -0700
Re: Keypress Input Terry Reedy <tjreedy@udel.edu> - 2015-07-16 03:10 -0400
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-07-16 15:29 -0600
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-15 05:23 +0000
Re: Keypress Input Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-06-15 12:22 +0100
Re: Keypress Input Grant Edwards <invalid@invalid.invalid> - 2015-06-15 15:22 +0000
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-06-16 11:15 -0600
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-16 20:06 +0000
Re: Keypress Input Grant Edwards <invalid@invalid.invalid> - 2015-06-16 20:49 +0000
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-06-16 19:22 -0600
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-06-18 16:42 -0600
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-06-20 15:02 +0000
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-06-20 10:30 -0600
Re: Keypress Input Paul Rubin <no.email@nospam.invalid> - 2015-06-16 14:22 -0700
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-07-15 19:05 +0000
Re: Keypress Input Michael Torrie <torriem@gmail.com> - 2015-07-15 13:17 -0600
Re: Keypress Input John McKenzie <davros@bellaliant.net> - 2015-08-16 19:45 +0000
csiph-web