[Tutor] Need to be able to accept Page Down or CTRL-E
davea at davea.name
Fri Feb 1 04:55:23 CET 2013
On 01/31/2013 10:19 PM, Dave Wilder wrote:
>>> On 01/31/2013 09:43 PM, Dave Wilder wrote:
>>> In a script I am writing, I would like to be able to accept the PAGE DOWN key as an input as well as the arrow keys.
>>> Is that possible w/ Python (I am using python 2.7.3 and Linux OS)? If so, could someone point me to documentation on how to do that?
>>> I have done things like this before in python. For example, I used the following to send the <ESC> character.
>>> send (chr(27))
>>> However, I have not been able to find the ascii code equivalent to use for PAGE DOWN and the up/down arrow keys.
>>> I'm not even sure this is even a python question.
>> So how are you taking this input in? If you're writing a terminal application, using raw_input(), it would be very difficult, as you'd probably have to modify the readline function.
>> Perhaps you're using some GUI. Please tell us which one.
>> - DaveA
> I am using a terminal application and an application called pexpect (instead of raw_input) where I send something to the console and then look for a result, such as <PAGE DOWN> or
> UP/DOWN arrows. I'm not sure if pexpect is standard Python application. I thought I recalled someone on this list saying it wasn't.
I don't use pexpect. But there is both a pexpect in the stdlib, and at
least one external library of the same name. So it may be relevant
which one you're using. But it's still quite confusing to me whether
you're writing the controlled app or the controlling app. And your
wording is confusing me still further, by referring to pexpect as an
Maybe somebody else can make sense out of it. Or maybe you should start
over, using names and verbal diagrams. Who is sending what to whom?
Which programs are you stuck with, which ones are you writing? If
you're writing all of it, why would you use pexpect?
More information about the Tutor