attributeError:模块' cursess'没有属性' a_italic'

发布于 2025-01-31 02:22:37 字数 330 浏览 4 评论 0 原文

由于某种原因,我无法确定为什么诅咒不会让我使用 a_italic 属性。

所有其他属性似乎都没有问题,但斜体特异性触发了错误消息。

我正在运行Python 3.10.4,这里有一些示例代码:

import curses

def main(stdscr):
    stdscr.addstr(0, 0, "This should be italicized!", curses.A_ITALIC)
    stdscr.getch()

if __name__ == '__main__':
    curses.wrapper(main)

For some reason, I cannot for the life of me figure out why curses won't let me use the A_ITALIC attribute.

All of the other attributes seem to work with no issues, but italic specifically triggers an error message.

I'm running Python 3.10.4, here's some sample code:

import curses

def main(stdscr):
    stdscr.addstr(0, 0, "This should be italicized!", curses.A_ITALIC)
    stdscr.getch()

if __name__ == '__main__':
    curses.wrapper(main)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁梦 2025-02-07 02:22:37

MacOS上的Python可以支持 A_ITALIC 如果它是使用Ncurses的最新版本构建的(因为 2013 ,例如,ncurses 6.x)。 MacOS的Ncurses的系统版本太旧了。

python在其他平台上也是如此,例如, netbsd 和旧版Unix系统。

使用python的最新版本,您可以使用版本 ncurses_version 函数。但是,即使有了最近的Ncurses版本,python中总会有可能会干扰该功能的错误。

python的质疑包装器(请参阅

    /* ncurses extension */
#ifdef A_ITALIC
    SetDictInt("A_ITALIC",          A_ITALIC);
#endif

更改基础ncurs不会影响这一点(除非Python重建)。

Python on MacOS could support A_ITALIC if it is built using a recent version of ncurses (since 2013, e.g., ncurses 6.x). The system version of ncurses for MacOS is far too old for that.

The same applies to Python on other platforms, e.g., NetBSD and legacy Unix systems.

With correspondingly recent versions of Python, you can check which version of ncurses using the version or the ncurses_version function. However, even with a recent ncurses version, there's always the possibility of a bug in Python which interferes with providing that feature.

Python's curses wrapper (see source) knows about the feature because its name is compiled-in when Python is built:

    /* ncurses extension */
#ifdef A_ITALIC
    SetDictInt("A_ITALIC",          A_ITALIC);
#endif

Changing the underlying ncurses would not affect that (unless Python is rebuilt).

迷路的信 2025-02-07 02:22:37

来自 curss curses document ::

可用的确切常数是系统依赖的。

我在MacOS上尝试了Python 3.9.12,但它不起作用,但是它确实使用了Docker容器中的Python 3.10.4使用。

From the curses documentation:

The exact constants available are system dependent.

I tried it in Python 3.9.12 on macOS, and it didn't work, but it did work using Python 3.10.4 in a Docker container.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文