Python curses, splitting terminal window in 4 pads - prefresh() returned ERR

Viewed 686

I'm running a multiprocessing system in Python, and I was planning to use curses to divide the terminal window in 4 quadrants, and display the output of each of the processes in one of them.

So, the final output should look something like:

--------------------------------
|               |               |
|   PROCESS01   |   PROCESS02   |
|               |               |
---------------------------------
|               |               |
|   PROCESS03   |   PROCESS04   |
|               |               |
---------------------------------

So far, I tried splitting the window in 4 pads, like this:


def main():

    screen = curses.initscr()
    cols_tot = curses.COLS
    rows_tot = curses.LINES
    cols_mid = int(0.5*cols_tot)   ## middle point of the window
    rows_mid = int(0.5*rows_tot)

    pad11 = curses.newpad(rows_mid, cols_mid)
    pad12 = curses.newpad(rows_mid, cols_mid)
    pad21 = curses.newpad(rows_mid, cols_mid)
    pad22 = curses.newpad(rows_mid, cols_mid)
    pad11.addstr(0, 0, "*** PROCESS 01 ***")
    pad12.addstr(0, 0, "*** PROCESS 02 ***")
    pad21.addstr(0, 0, "*** PROCESS 03 ***")
    pad22.addstr(0, 0, "*** PROCESS 04 ***")
    pad11.refresh(0,0, 0,0, rows_mid,cols_mid)
    pad12.refresh(0,cols_mid, 0,cols_mid, rows_mid,cols_tot-1)
    pad21.refresh(rows_mid,0, rows_mid,0, cols_tot-1,rows_mid)
    pad22.refresh(rows_mid, cols_mid, rows_mid,cols_mid, rows_tot-1,cols_tot-1)


    curses.napms(3000)
    curses.endwin()


if __name__ == '__main__':
    main()

but I'm getting the error:

File "screen_show.py", line 78, in <module> main()
                                                                                                          File "screen_show.py", line 46, in main
                                                                                                                                                     pad12.refresh(0,cols_mid, 0,cols_mid, rows_mid,cols_tot-1)
_curses.error: prefresh() returned ERR
0 Answers
Related