Reputation: 379
I have started to write console with Python language. It is amazing. But, I have tried to create input box with curses
as shown below. I have stucked in how I can put input line and get the input written on the input place on the console. Can you help me for this part ? I forget to ask _is it possible to create input box as shown below with curses ? If not, what should I use ?
I just want to see the methods/algorithms not the whole and complete code.
sketch of console
|------------------------------------------------------|
| |
| |
| |
| |
| username ===> | // user can write name
| password ===> | // user can write password
| procedure ===> | // user can write proc name
| |
| |
| |
| |
| |
|------------------------------------------------------|
I am developing on the Linux platform ( Ubuntu 12.04 lts )
Upvotes: 2
Views: 764
Reputation: 102852
Somehow my previous answer got deleted...
To get user input in Python, assign a variable to the results of the built-in input()
function:
user_input = input("Type something: ")
print("You typed: " + user_input)
In Python 2, the raw_input()
function is also available, and is preferred over input()
.
To get the password without it echoing back to the screen, use the getpass
module:
import getpass
user_password = getpass.getpass("Enter password: ")
I'm not that familiar with curses
, but it would seem that you could position your cursor, then call input()
or getpass.getpass()
. Just briefly reading over the documentation, there are apparently options to turn screen echoing on and off at will, so those may be better options. Read The Fine Manual :)
Upvotes: 1