【问题标题】:How to run WindowCommand plugin from `sublime console`如何从“崇高控制台”运行 WindowCommand 插件
【发布时间】:2013-11-09 17:52:26
【问题描述】:

我使用 3 个命令为 sublime text 3 创建了插件: 其中2个是TextCommand类型,其中一个是WindowCommand

import sublime, sublime_plugin

class simple_text_pluginCommand(sublime_plugin.TextCommand):
    def run(self, edit):      
        print("Hello World simple_text_plugin")
class simple_text_plugin2Command(sublime_plugin.TextCommand):
    def run(self, edit):      
        print("Hello World simple_text_plugin2")        
class simple_window_pluginCommand(sublime_plugin.WindowCommand):
    def run(self):      
        print("Hello World simple_window_plugin")  

为什么我只能从sublime command line (ctrl + `) 调用文本命令:

>>> view.run_command('simple_text_plugin') 
Hello World simple_text_plugin

>>> view.run_command('simple_text_plugin2') 
Hello World simple_text_plugin2

但是不能调用window命令:

>>> view.run_command('simple_window_plugin') 

没有输出。如何从sublime console运行Window类型插件?

【问题讨论】:

标签: python plugins sublimetext2 sublimetext sublimetext3


【解决方案1】:
  • ApplicationCommandsublime.run_command('application_command_name')。在API reference 中检查sublime 模块的run_command 函数。
  • WindowCommandwindow.run_command('window_command_name')。检查sublime.Windowrun_command方法。
  • TextCommandview.run_command('text_command_name')。检查sublime.Viewrun_command方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 2015-09-03
    • 2012-09-17
    • 1970-01-01
    相关资源
    最近更新 更多