By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

python script reading special keys like <F1>, <F2> etc.

P: n/a
I am planning to write a very simple python script that displays files
based on user input. E.g. I need to display f1.msg file if the user
presses <F1key, f2.msg file if the user presses <F2key. What is the
easiest way to do this on Linux (xterm/vt100/asni etc). I tried using
curses and it works, but I want something that does NOT modify or redraw
the user screen.

Something like this:
def display():
key = raw_input()
if key == <F1>
sys.stdout.write(open(f1.msg, "r").read())
elif key == <F2>
sys.stdout.write(open(f2.msg, "r").read())
else: # I need to capture his input string too.
return key
I can make a restriction that the user press <Enterafter typing the
above keys if required. Is there a solution that doesn't redraw the
screen like curses does and kind of portable at the same time to
different terminals on Linux/Unix?
Jul 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.