gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 00:36:19 26 4
gpt4 key购买 nike

我使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com