Question

When using curses in Python, I know how to use stdscr which is returned by curses.initscr(). How do I access curscr which holds the current screen image?

Background: I have several (overlapping) windows. To make them look nice, I added shadows. For even more candy I wanted the shadow to be a black and white version of the underlying text, so I need to get the text my window shadow is covering. If I use stdscr.inch(y, x), I get all blanks, since my stdscr is empty (everything is displayed using windows).

The ncurses C API contains curscr, which I believe solves my problem. The only other solution for the moment would be to keep track of all existing windows (which I already wrapped in python classes) and in case I need to get a character from the screen, iterate through all known windows and check if they intersect my test point (adding more complexity because I would need to implement Z axis management, too).

How it looks like at the moment (notice how the white context menu overlaps the bus node windows not using the correct attributes for lower left/upper right corners):

Screenshot from my home automation text interface over ssh

Was it helpful?

Solution

Although I did not find a solution to use curscr, I implemented my own window manager class which takes care of the proper refresh order and doesn't need curscr for correct overlapping.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top