Grabbing Keystrokes Within A GUI Application

Tim Daneliuk tundra at tundraware.com
Wed Nov 6 18:50:07 EST 2002


It has been several centuries since I last wrote GUI code, so I
stipulate that the following question may be Moronic, however ...
---------------------------------------------------------------------

Part of Python's appeal for me was the lower ramp-up time to getting GUI
applications to work. In an effort to retrain my command line brain to
think GUI-ly again, I decided to start with 'anygui' as a learning
exercise. [I am unclear on just how good/stable the current 'anygui'
code actually is, but, for the moment, it serves my purposes.]

I now have the skeleton of a GUI-driven utility which allows me to
navigate through a file system. When I select a directory, it moves
there. When I click on a file, I do nothing (for now).

Now, here's the part my elderly brain does not get. During all this
mousing, suppose I want to capture keystrokes. In my case, I want to
first select a file visually, and then use a single letter to perform an
operation on it - 'e' for emacs, 'm' for more, and so on. I am hacking
my way to some visual composite of mc, less, and MS Winders Explorer, I
guess.

In the Bad Old Days, I recall hooking into the GUI message handling loop
and looking for messages indicating keyboard input. There appears to be
no such animal, at least in 'anygui'.

Does anyone have suggestions on how this might be accomplished. I am
willing to learn that 'anygui' is not yet stable/feature-laden enough to
do the trick, in which case I will go learn Tkinter as needed.
Similarly, responses in the form of, "You big dummy, this is Soooo, easy
to do..." are fine, but hopefully a pointer to someplace which 'splains
it to me will also be included in that case...

TIA,
-- 
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com




More information about the Python-list mailing list