为Ascimatics设置默认背景

2024-10-01 07:49:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我理解不可能告诉Ascimatics使用终端的当前配色方案(因为asciimatics无法查询终端)。但是我希望至少有一些控制,并且能够自己选择配色方案

我在文档中找不到如何更改默认前景/背景颜色

我正在使用standard demo

from asciimatics.screen import Screen
from asciimatics.scene import Scene
from asciimatics.effects import Cycle, Stars
from asciimatics.renderers import FigletText

def demo(screen):
    effects = [
        Cycle(
            screen,
            FigletText("ASCIIMATICS", font='big'),
            screen.height // 2 - 8),
        Cycle(
            screen,
            FigletText("ROCKS!", font='big'),
            screen.height // 2 + 3),
        Stars(screen, (screen.width + screen.height) // 2)
    ]
    screen.play([Scene(effects, 500)])

Screen.wrapper(demo)

我想背景是黄色的。不是文本元素的背景,而是整个背景(我想说的是Screen的背景)

我该怎么做


Tags: fromimport终端demo方案scenescreen背景
1条回答
网友
1楼 · 发布于 2024-10-01 07:49:43

对您的问题的简短回答是将Background效果添加到Scene中。如文档所述here,您可以设置任何背景颜色

但是,有些效果比其他效果更老,并且早于背景颜色支持。遗憾的是,CycleStars都在这个列表中,因此没有等效的bg设置,因此需要进行更新才能按预期进行更改。我怀疑它们也需要调整,以期待后台将强制执行的完全刷新。如果需要,请访问asciimatics gitter频道

相关问题 更多 >