我想在 tmux 的窗格中显示动画 GIF 或任何其他图像。
我正在使用asciimatics来做到这一点,并将其中一个示例程序(images.py)修改为:
- 显示单个图像
- 在“Ctrl+C”上不显示错误消息
- 接受单个命令行参数“图像文件名”
这是我的脚本,唯一的问题是它似乎每 10 秒对正在显示的图像进行一次缓慢的刷新。由于图像是静态图像,如何删除此刷新?
图像.py
from __future__ import division
from asciimatics.effects import BannerText, Print, Scroll
from asciimatics.renderers import ColourImageFile, FigletText, ImageFile
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError
import sys
total = len(sys.argv)-1
if (total < 1):
print ("Usage: IMG")
sys.exit(1)
# Parsing args one by one
IMG = str(sys.argv[1])
def demo(screen):
scenes = []
effects = [
Print(screen,
ColourImageFile(
screen, IMG,
screen.height-2,
uni=screen.unicode_aware,
dither=screen.unicode_aware),
0,
stop_frame=200
)
]
scenes.append(Scene(effects))
screen.play(scenes, stop_on_resize=True)
# capture ctrl+c and exit nicely
import signal
import sys
def signal_handler(sig, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
if __name__ == "__main__":
while True:
try:
Screen.wrapper(demo)
#Screen.wrapper(demo, catch_interrupt=True)
sys.exit(0)
except ResizeScreenError:
sys.exit(0)