Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to create a separate display and input on the same terminal using curse?

Tags:

python

curses

I'd like to code a command line program that result in this UI:

------------
|          |
|     A    |
|__________|
|_____B____|

A is a separate process that loops and displays a list of real time events. It self-refresh.

B is a command prompt. It's fixed at the bottom and got a command history.

I know some command line IRC programs does this so it must be possible.

Bonus point if you can give me a snippet using a Python binding.

I'm aware of this post but I'm kind of lost in the curse documentation.

like image 281
e-satis Avatar asked Apr 20 '11 08:04

e-satis


People also ask

How do you get input on curses?

User Input The most common way to get input to a window is to use its getch() method. getch() pauses and waits for the user to hit a key, displaying it if echo() has been called earlier. You can optionally specify a coordinate to which the cursor should be moved before pausing.

What is stdscr in Python?

The stdscr object returned by the initscr() function is a window object that covers the entire screen. Many programs may need only this single window, but you might wish to divide the screen into smaller windows, in order to redraw or clear them separately.

What is curses module?

The curses module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling. While curses is most widely used in the Unix environment, versions are available for Windows, DOS, and possibly other systems as well.


1 Answers

Enventually I tried to do it with urwid which is way higher level than ncurse.

I asked a question about it on SO and didn't got more results.

But eventually I found some FOSS that did just that, I used the source code and made something that worked. You can find the answer in the related question.

like image 94
e-satis Avatar answered Oct 23 '22 07:10

e-satis