0

I have a Python-3 application that has an interactive command-line interface. Now I would like to add non-canonical keyboard input functionality to this application. I would like it to behave much like how Python interpreter handles its keyboard inputs - for example, keys like up-arrow and down-arrow could scroll command histories and other control keys could move the cursor to beginning/end of line, etc.

I had a cursory glance of getkey and keyboard modules, but what is the best (and easiest) Python 3 module that I could use for this feature?

1
  • there are special modules for command line - even IPython use one of them - Python Prompt Toolkit. Even standard module cmd should have some of this functions. Most of them use modul readline for this. Commented Mar 4, 2020 at 2:50

1 Answer 1

2

There are special modules to create interactive command line.

They can use special keys to show history, edit line, auto suggestions.

There is standard module cmd which should have this functionality.

See also extended cmd2

Probably the most popular is Python Prompt Toolkit. Probably even IPython uses it.

See Gallery, basic tutorila and examples with PtPython

enter image description here

Probably most of them use standard modul readline - so maybe you will need this for your project.


Other


BTW: 4 Python libraries for building great command-line user interfaces

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Thanks for taking the time to respond. I am using python-prompt for my needs and it works great! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.