Skip to content Skip to sidebar Skip to footer

Present Blank Screen, Wait For Key Press -- How?

'lo, I am currently trying to code a simple routine for an experiment we are planning to run. The experiment starts by entering a subject number and creating a bunch of files. I go

Solution 1:

If you're in python 2, use raw_input().

If you're using python 3, use input().

You can prompt the user for information and store the result as a string.

in python 2.x

response = raw_input("What would you like to do next?")

in python 3.x

response = input("What would you like to do next?")

Solution 2:

On windows, you can use functions in the msvcrt module. For example, kbhit() waits until the user presses a key.

Solution 3:

To print the blank screen before putting the prompt, I used the following

import os
import sys

VALIDINPUT = '0'while VALIDINPUT == '0':
    p = os.popen('clear')
    for line1 in p.readlines():
    print line1
    <put the logic for reading user input here>
    <put the logic to check for valid user input here andif the user input is valid, then
    assign 1 to VALIDINPUT>

This will show a blank screen and the prompt until the user provides a valid input.

Hope this helps. I used this on Linux.

Solution 4:

raw_input('Please fill in questionnaire 1 and press [ENTER] when you are done.') will wait for someone to hit [enter].

Clearing the screen may be OS/environment dependent, I am not sure.

Post a Comment for "Present Blank Screen, Wait For Key Press -- How?"