how do I stop the screen scrolling ?

Bengt Richter bokr at oz.net
Mon Nov 3 23:37:56 EST 2003


On Mon, 3 Nov 2003 23:56:39 -0800, "ruari mactaggart" <ruari at charliefortune.com> wrote:

>how do I put a pause, 'hit any key to continue' type thing in printing a
>long dictionary on the screen, please ?
>
If you want _any_ key, you'll have to go to a little trouble (see msvcrt module's getch etc.,
but even then you won't be able to catch e.g., Ctrl-Alt-Del and probably some others. If you
do it that way, you may want to use kbhit to make sure there's nothing pending that would
proceed immediately, and nothing left over (like a second char from a function key) when you
finish), but if you're satisfied with the Enter key, it's very simple and built in:

    raw_input('Press Enter to continue ;-) ')

You can of course capture whatever string was typed up to the Enter if you like:

 >>> theString = raw_input('Please type something and press Enter: ')
 Please type something and press Enter: something
 >>> theString
 'something'
 >>>

Also, depending on what is doing the scrolling, Ctrl-s and Ctrl-q might stop and start it.

Regards,
Bengt Richter




More information about the Python-list mailing list