标签: curses

ImportError:尝试导入祝福时没有名为'_curses'的模块

我试图运行这个:

from blessings import Terminal

t = Terminal()

print (t.bold('Hi there!'))
print (t.bold_red_on_bright_green('It hurts my eyes!'))

with t.location(0, t.height - 1):
    print ('This is at the bottom.')
Run Code Online (Sandbox Code Playgroud)

这是第一个例子:https://pypi.python.org/pypi/blessings.

但是,我收到此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\?????\AppData\Local\Programs\Python\Python35-     32\lib\site-packages\blessings\__init__.py", line 5, in <module>
    import curses
  File "C:\Users\?????\AppData\Local\Programs\Python\Python35-32\lib\curses\__init__.py", line 13, in <module>
    from _curses import *
ImportError: No module named '_curses'
Run Code Online (Sandbox Code Playgroud)

我的系统是win10 x64.

python windows curses module python-curses

21
推荐指数
3
解决办法
2万
查看次数

诅咒得到箭头键

在尝试通过curses(ncurses)从箭头键获取输入时,它不会捕获KEY_UP等.我使用带有true参数的键盘函数但是getch仍然返回一个转义序列.如何筛选getch()返回的值并专门抓取箭头键?

c curses key input ncurses

17
推荐指数
3
解决办法
2万
查看次数

如何在Python curses中创建菜单和子菜单?

AFAIK,Python中没有可用的curses菜单扩展,所以你必须推出自己的解决方案.我知道这个补丁http://bugs.python.org/issue1723038,但我不知道它的当前状态.我找到了一个很好的Python类,在http://www.promisc.org/blog/?p=33包含了我想要的'cmenu',但我也遇到了问题.我想创建一个菜单,用户可以选择一个突出显示的元素,但不是立即执行特定的操作,我想显示另一个菜单,然后可能是另一个,请求输入等.我的第一个想法是删除现有的cmenu screen.clear()或cleanup()但是在绘制新菜单之前不会删除旧菜单,新菜单如下所示:

    0. top
    1. Exit
    2. Another menu
-- end of the old menu that should go away --
    3. first
    4. second
    5. third
Run Code Online (Sandbox Code Playgroud)

没有用于删除cmenu()中项目的remove()方法.我想旧的菜单没有被清除的事实是由display()方法中的'while True'循环引起的,但是当我删除它时,一些奇怪的东西正在发生.我使用的是Python 2.7,这是我目前的代码:

#!/usr/bin/python
#
# Adapted from:
# http://blog.skeltonnetworks.com/2010/03/python-curses-custom-menu/
#
# Goncalo Gomes
# http://promisc.org
#

import signal
signal.signal(signal.SIGINT, signal.SIG_IGN)

import os
import sys
import curses
import traceback
import atexit
import time

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

class cmenu(object):
    datum = {}
    ordered = []
    pos = 0

    def __init__(self, …
Run Code Online (Sandbox Code Playgroud)

python curses python-2.7

16
推荐指数
1
解决办法
3万
查看次数

CMake无法找到诅咒

我正在尝试从www.marcansoft.com编译openlase库并且遇到了CMake的问题.CMake正在返回一个错误,指出它无法找到Curses,经过大量的审视后,我仍然对这个问题感到难过.我已经检查过我安装了各种ncurses软件包,但仍然存在错误.我对CMake不太熟悉,但我能够解决在此之前出现的其他依赖性问题.以下是终端输出.

tom@SILVER:~/dev/openlase$ cmake ./
-- Found JACK 
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:70 (MESSAGE):
  Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindCurses.cmake:159 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  examples/27c3_slides/CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

  • 汤姆

linux curses ncurses cmake

14
推荐指数
4
解决办法
4万
查看次数

Python:将密钥代码解析为可读(vim-like?)语法

我想在基于curses的python程序中提供键绑定.理想的解决方案是在周围设置一个抽象层getch(),产生可读的字符串,可能采用类似vim的格式.

在pythonese:

def get_keycomb(wind):
    string = read_keycomb(wind) # read with wind.getch() as needed
    return string # something like '<C-S-a>'
Run Code Online (Sandbox Code Playgroud)

然后,我可以通过将字符串用作dict函数中的键来轻松实现映射.

是否有一个python库提供这种功能,或者比手动为所有内容提供名称更容易实现它?

python curses vim

14
推荐指数
1
解决办法
1353
查看次数

有没有办法交互式编程Python curses应用程序?

有没有办法创建第二个终端,以便所有对curses函数的调用都在那个,而不是在现有的终端上?当我可以以交互方式尝试时,我工作得更快,所以我希望能够在一个终端中运行交互式python解释器,并在另一个终端中查看curses输出.

实际上,initscr()在交互式窗口中调用失败(PyDev)或永久地从主机(Spyder)中取消窗口刷新或在控制台(IPython)中导致奇怪的行为.

是否可以使用不同的终端接管setupterm()?如果是这样,我在哪里可以使用不同的TERM字符串来调用它?

python curses

13
推荐指数
1
解决办法
1565
查看次数

中断(n)诅咒输入信号

我的一个程序使用ncurses绘制一个小的tui.我的目标之一是使其可以移植到其他curses实现.这意味着我想在自己的调整大小操作上捕获终端模拟器发出的SIGWINCH,并更新我的tui以遵守更改的几何(并且不依赖于ncurses的调整大小设施).由于POSIX(据我所知)只允许访问sig_atomic_t信号处理程序中的变量,因此我将其设置为不同的状态.在主循环中,我的程序检查状态是否已更改并在必要时更新tui.

但是现在,getch当信号到达时,我遇到了我的程序挂起的问题.ncurses文档声明处理信号永远不会中断它.这意味着在按下输入键之前不会更新tui的大小.

是否有任何可移植的中断方式getch?我目前的方法是ungetch在信号处理程序中使用虚拟键,但我不确定是否允许这样做.实际上我找不到任何关于是否可以在信号处理程序中使用curses函数的文档.知道如何正确处理这件事吗?

问候

c curses posix tui ncurses

13
推荐指数
2
解决办法
2380
查看次数

如何管理curses中的日志记录

我使用curses为我的应用程序创建了一个简单的UI,并且还使用层次结构(logmain,logmain.child1)等在我的模块中包含日志(日志记录).

如果发生日志事件,日志将显示在我的UI中,从而破坏其外观.我还创建了一个pad(myLogPad),以便输入传入的日志,但没有成功.我如何拦截日志事件并将其打印在我的屏幕的特定区域(最后一行)?

def setupLogger(name,file_name):
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
#formatter = logging.Formatter(
#    "%(asctime)s %(threadName)-11s %(levelname)-10s %(message)s")
formatter = logging.Formatter('%(asctime) -25s - %(name) -15s - %(levelname) -10s - %(message)s')
formatterDisplay = logging.Formatter('%(asctime)-8s|%(name)-12s|%(levelname)-6s|%(message)-s', '%H:%M:%S')
# Alternative formatting available on python 3.2+:
# formatter = logging.Formatter(
#     "{asctime} {threadName:>11} {levelname} {message}", style='{')

# Log to file
filehandler = logging.FileHandler(file_name, 'w')

filehandler.setFormatter(formatter)
logger.addHandler(filehandler)

# Log to stdout too
streamhandler = logging.StreamHandler()

streamhandler.setFormatter(formatterDisplay)
logger.addHandler(streamhandler)
Run Code Online (Sandbox Code Playgroud)

我尝试在streamhandler = logging.StreamHandler()中传递mylog pad但没有成功.任何的想法?谢谢

python curses logging intercept

12
推荐指数
2
解决办法
2133
查看次数

python celery - ImportError:没有名为_curses的模块 - 在尝试运行manage.py celeryev时

背景

Windows 7 x 64 Python 2.7 Django 1.4 Celery与Redis捆绑

在尝试运行manage.py celeryev时,我在终端中收到以下错误

import curses
File 'c:\Python2\lib\curses\__init__.py', line 15, in <module> from _curses import *
ImportError: No module named _curses
Run Code Online (Sandbox Code Playgroud)

我试过看其他帖子,但一直无法解决这个问题.有关导致此错误的原因的任何想法?提前致谢.

python curses celery

11
推荐指数
1
解决办法
1万
查看次数

错误没有名为curses的模块

当我尝试运行以下代码时......

from telnetsrvlib import *

if __name__ == '__main__':
"Testing - Accept a single connection"
class TNS(SocketServer.TCPServer):
    allow_reuse_address = True

class TNH(TelnetHandler):
    def cmdECHO(self, params):
        """ [<arg> ...]
        Echo parameters
        Echo command line parameters back to user, one per line.
        """
        self.writeline("Parameters:")
        for item in params:
            self.writeline("\t%s" % item)
    def cmdTIME(self, params):
        """
        Print Time
        Added by dilbert
        """
        self.writeline(time.ctime())

logging.getLogger('').setLevel(logging.DEBUG)

tns = TNS(("0.0.0.0", 8023), TNH)
tns.serve_forever()
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

Traceback (most recent call last):
File ".\telserv.py", line 1, in <module>
from …
Run Code Online (Sandbox Code Playgroud)

python windows curses telnet python-2.7

11
推荐指数
4
解决办法
6万
查看次数

标签 统计

curses ×10

python ×7

ncurses ×3

c ×2

python-2.7 ×2

windows ×2

celery ×1

cmake ×1

input ×1

intercept ×1

key ×1

linux ×1

logging ×1

module ×1

posix ×1

python-curses ×1

telnet ×1

tui ×1

vim ×1