nob*_*be4 9 python sublimetext3 sublime-text-plugin
要了解我想要实现的目标:在另一个视图中打印延迟文本...
我正在尝试使这个崇高的文本3插件正常运行我想使用我的run方法的参数传递的编辑调用我的类的多个方法,如下所示:
# sample code, nothing real
class MyCommandClass(sublime_plugin.TextCommand):
myEdit = None
def run(self, edit):
self.myEdit = edit
# stuff
self.myMethod()
def myMethod(self):
# use self.myEdit ...
Run Code Online (Sandbox Code Playgroud)
我尝试稍后在另一个方法上使用它,但是当我执行插件时,我收到此错误:
ValueError: Edit objects may not be used after the TextCommand's run method has returned
据我所知,编辑对象的所有使用必须在返回run命令之前.在我玩的时候set_timeout,情况可能并非如此......那我该怎么办?
提前致谢.
nob*_*be4 12
找到解决方案,将参数传递给另一个视图并使用编辑:
class MainCommand(sublime_plugin.WindowCommand):
def run(self):
newFile = self.window.new_file()
newFile.run_command("second",{ "arg" : "this is an argument"});
class SecondCommand(sublime_plugin.TextCommand):
def run(self, edit, argument):
# do stuff with argument
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
781 次 |
| 最近记录: |