【问题标题】:how do you disable a text command from another text command in Sublimetext如何从 Sublimetext 中的另一个文本命令中禁用文本命令
【发布时间】:2015-08-06 08:11:37
【问题描述】:

我正在 sublime Text 3 中创建一个插件,但我遇到了一个我无法弄清楚的问题。这是我第一次使用 python,也是十多年来我第一次做驱动桌面开发,所以希望这只是我缺乏知识。

我正在编写的插件使用文本命令来收集数据,然后使用该数据调用另一个文本命令,该命令启动一个子进程,该子进程可以运行很长时间,具体取决于传递的参数。

以下是一些简化的代码。

BlaOneCommand 类(sublime_plugin.TextCommand): def 运行(自我,编辑): 命令参数 = [] self.view.run_command('run_command', {"args": commandArgs}) BlaTwoCommand 类(sublime_plugin.TextCommand): def 运行(自我,编辑): 命令参数 = [] self.view.run_command('run_command', {"args": commandArgs}) BlaThreeCommand 类(sublime_plugin.TextCommand): def 运行(自我,编辑): 命令参数 = [] self.view.run_command('run_command', {"args": commandArgs}) BlaRunCommand 类(sublime_plugin.TextCommand): def 运行(自我,编辑,参数): self.commandArgs = 参数 sublime.set_timeout_async(self.runCommand, 0) 定义运行命令(自我): 过程 = '' 如果 os.name == 'nt': 启动信息 = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW proc = subprocess.Popen(self.commandArgs,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False,startupinfo=startupinfo) 别的: proc = subprocess.Popen(self.commandArgs,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False) 而 proc.poll() 为无: 尝试: 数据 = proc.stdout.readline().decode(encoding='UTF-8') 打印(数据,结束=“”) 除了: 返回;

BlaOne、BlaTwo 和 BlaThree 在上下文菜单中设置。我需要做的是在子进程运行时禁用部分或全部。我知道这可以通过覆盖 is_enabled 方法来完成。但是,我正在为如何将它们捆绑在一起而苦苦挣扎。

如何让所有对象相互感知,以便它们能够相互启用/禁用?

【问题讨论】:

    标签: python sublimetext3 sublimetext sublime-text-plugin


    【解决方案1】:

    又读了 5 个小时,我明白了。正如我所认为的,这是我缺乏 Python 知识。

    我需要做的就是创建一个模块级变量以用作标志。

    【讨论】:

      猜你喜欢
      • 2022-01-26
      • 1970-01-01
      • 2020-10-09
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多