I'm creating a plugin in sublime Text 3, and I've hit a snag that I can't figure out. This is my first using python, and the first time I've done even driven desktop development in over a decade, so hopefully this is just a lack of knowledge on my part.
The plugin I'm writing uses text commands to gather data and then uses that data to call another text command that starts a subprocess than can run for a significant period of time depending on the arguments passed.
the following is some simplified code.
class BlaOneCommand(sublime_plugin.TextCommand):
def run(self, edit):
commandArgs = []
self.view.run_command('run_command', {"args": commandArgs})
class BlaTwoCommand(sublime_plugin.TextCommand):
def run(self, edit):
commandArgs = []
self.view.run_command('run_command', {"args": commandArgs})
class BlaThreeCommand(sublime_plugin.TextCommand):
def run(self, edit):
commandArgs = []
self.view.run_command('run_command', {"args": commandArgs})
class BlaRunCommand(sublime_plugin.TextCommand):
def run(self, edit, args):
self.commandArgs = args
sublime.set_timeout_async(self.runCommand, 0)
def runCommand(self):
proc = ''
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(self.commandArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, startupinfo=startupinfo)
else:
proc = subprocess.Popen(self.commandArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
while proc.poll() is None:
try:
data = proc.stdout.readline().decode(encoding='UTF-8')
print(data, end="")
except:
return;
BlaOne, BlaTwo, & BlaThree are set up in a context menue. and what I need to do is disable some or all of them while the subprocess is running. I know this can be done by overriding the is_enabled method. However I'm struggling with how to tie them all together.
How can I make all the objects aware of each other, so they can enable/disable each other?