2013-10-30 72 views
4

我創建插件sublime text 3 3個命令運行WindowCommand插件:他們的型的,其中之一是WindowCommand如何從`崇高console`

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類型的插件?

+1

使用'window.run_command(「simple_window_plugin」)'。檢查這篇文章http://stackoverflow.com/questions/19532204/in-sublime-why-is-def-run-working-in-one-case-and-not-another-case-and-how-can/19533899 #19533899。 – longhua

回答

10
  • ApplicationCommandsublime.run_command('application_command_name')。在API reference中檢查sublime模塊的run_command函數。
  • WindowCommandwindow.run_command('window_command_name')。檢查run_command方法sublime.Window
  • TextCommandview.run_command('text_command_name')。檢查run_command方法sublime.View