为了理解我要达到的目的:在另一视图中打印延迟的文本...
我正在尝试使此sublime text 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 ...
我稍后尝试在另一种方法上使用它,但是当我执行插件时,出现此错误:
ValueError: Edit objects may not be used after the TextCommand's run method has returned
据我了解,对edit对象的所有使用都必须在run命令返回之前。在我玩游戏时set_timeout
,情况可能并非如此...那我该怎么办?
提前致谢。
找到解决方案,将参数传递给另一个视图并使用edit:
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句