python - 如何从 `sublime console` 运行 WindowCommand 插件

标签 python plugins sublimetext2 sublimetext sublimetext3

我使用 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 命令行 (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 类型的插件?

最佳答案

  • 应用程序命令:sublime.run_command('application_command_name')。检查 API referencesublime 模块的 run_command 函数.
  • WindowCommand:window.run_command('window_command_name')。检查 sublime.Windowrun_command 方法.
  • TextCommand:view.run_command('text_command_name')。检查 sublime.Viewrun_command 方法.

关于python - 如何从 `sublime console` 运行 WindowCommand 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19677478/

相关文章:

java - 通过 Python 执行 Java 程序

Eclipse 的颜色主题问题

node.js - Nodejs 构建 sublime-text2

amazon-web-services - Amazon EC2 上的远程端口转发失败

python - Numpy:对于一个数组中的每个元素,找到另一个数组中的索引

python - 根据包含 N (pandas) 的另一列获取一列月份的前 N ​​个月

python - Flask-SQLAlchemy 的隔离级别

NetBeans 作为 ColdFusion 脚本的编辑器?

jquery - 如何在 body 标签之后但在 body 标签内动态放置 html?查询

sublimetext2 - 将\n 替换为 Sublime Text 中的实际新行