python: threading & curses


I am trying to make a console interface to a python script that consists of threads.

Each thread has its own logger. And it constantly writes its log file.

The conductor, the main thread, must be able to switch stdout from one thread to another, and the general status, somewhere at the top to shine, "how much is the total flow", control, stop / start switch for each of the threads, the q button – to bind to quit , and etc.

In this case, loggers must print logs continuously so that they can be read. But the interface will be more convenient if the log of each thread is displayed separately from the rest, otherwise an unreadable mess is obtained.

How to do it simply?

stdscr = curses.initscr()
stdscr.addstr(0, 10, line_of_log)

curses puts a line on the screen so that if a line of the log is added from the bottom / top, then the shift of the entire text is a redrawing of the entire screen or what?

There is a similar construction that I want to implement in tor-arm , and I'm reading it now.

Besides curses is there any way to do this?


In order for each log to be displayed in a separate curses window, it is enough logging.Handler add logging.Handler to each logger (each its own, if necessary). Here is an example Handler that prints to the screen using curses .

Scroll to Top