是否可以在 Sublime Text 3 输出面板中显示图像?

Dju*_*uka 4 python sublimetext3 sublime-text-plugin

我正在编写一个 sublime text 3 插件。我有一个图像(PNG 格式)。我想将此图像加载到 Sublime Text 3 自定义输出面板中,以将其显示为预览。有谁知道如何做到这一点,或者甚至有可能吗?

ser*_*oFC 5

似乎输出面板只能呈现 unicode 字符,因此无法在其中放置图像(也许有一天)。

替代解决方案

正如我在评论中所说,您可以划分布局并使用选项卡来显示图像,如果需要,也可以使用选项卡来显示文本。我制作了这个简单的示例插件和两个屏幕截图:

import sublime, sublime_plugin

class Example(sublime_plugin.WindowCommand):
    def run(self):
        """Divide layout"""
        self.window.set_layout({
            "cols": [0.0, 0.4, 1.0],
            "rows": [0.0, 0.6, 1.0],
            "cells": [[0, 0, 2, 1], [0, 1, 1, 2], [1, 1, 2, 2]]
            })

        """Open image in group 1"""
        self.window.focus_group(1)
        self.window.open_file('/home/sergio/Escritorio/images/logo.png')

        """Show output/info in group 2"""
        self.window.focus_group(2)
        v = self.window.new_file()
        self.window.run_command('insert', {'characters': ("Plugin output:\n"
            "-Stackoverflow\n"
            "-is\n"
            "-very\n"
            "-cool\n"
            "-the\n"
            "-best\n"
            "-websites\n"
            "-of\n"
            "-the\n"
            "-world\n")})
        v.show_at_center(0)

        self.window.focus_group(0)
Run Code Online (Sandbox Code Playgroud)

之前的布局:

之前的布局

之后的布局:

布局后

请记住,这是一个简单的示例,它不会关闭打开的选项卡,也不会恢复布局等。