curses.intscr()的Python问题 [英] Python issue with curses.intscr()

查看:110
本文介绍了curses.intscr()的Python问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Python的新手,我在脚本中使用curses.

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

但是当我尝试在服务器上运行脚本时(让我说1),我遇到了以下错误.

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

_curses.error: addstr() returned ERR

同样的脚本,当我尝试在另一台服务器上运行时(假设2),它成功运行.

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

原因是服务器1产生了更多的数据以显示在屏幕上,而服务器1产生了更少的数据以显示在屏幕上.

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

因此,在搜索时发现curses.intscr()可以固定屏幕大小,这就是产生错误的原因.

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.

我正在linux中执行此脚本.

And I am executing this script in linux.

推荐答案

您可以尝试拆分巨大"字符串:

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

这是此问题的答案: 将文本设置为适合Python/Curses框中的格式

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

这篇关于curses.intscr()的Python问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆