Python issue with curses.intscr()

时光毁灭记忆、已成空白 提交于 2019-12-02 17:18:02

问题


I am new in Python and I am using curses for my script.

But when I am try to run the script in server(let say 1) I am getting below error.

_curses.error: addstr() returned ERR

And the same script when I am try to run in another server(let say 2) it is running successfully.

The reason is server 1 is producing more data to display on screen and server 1 is producing less data to display on screen.

So while searching found that curses.intscr() getting the screen size fixed and that's why it is producing error.

So is there any way to overcome it or to increase the screen resolution.

And I am executing this script in linux.


回答1:


You could try splitting your "huge" string:

from __future__ import division #You don't need this in Python3
from math import *
string = "0123456789012345678901234567890123456789"
columns = 5
rows = int(ceil(len(string)/columns))
for row in range(1,rows+1):
    panel.addstr(row,1,string[(row*columns)-columns:row*columns])

This will print these strings from the starting one:

01234
56789
01234
56789
01234
56789
01234
56789

This was the answer to this question: Formatting text to fit within a box in Python/Curses



来源:https://stackoverflow.com/questions/18945971/python-issue-with-curses-intscr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!