tmux - 如何在窗格中显示图像?

tmux - how to display an image in a pane?

我想在 tmux 的窗格中显示动画 GIF 或任何其他图像。

我正在使用 asciimatics 进行此操作,并将其中一个示例程序 (images.py) 修改为:

这是我的脚本,唯一的问题是它似乎每 10 秒对正在显示的图像进行一次缓慢的刷新。由于图像是静态图像,如何删除此刷新?

image.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)

我只需要设置 stop_frame=0 就可以正常工作,正如指定的那样 in the docs

用法示例

$ python image.py /images/fox.jpg

image.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)