THE PROBLEM
In short, below works but only when hardcoded like this.
class GetWindowCommand(sublime_plugin.WindowCommand):
#NEED VARIABLE INSTEAD OF THE HARDCODED "qv" string
sublime.active_window().run_command("get_window",{"qualifier": "qv"})
def __init__(self,window):
self.window=window
def run(self,qualifier):
self.projectFolders(qualifier)
def projectFolders(self,qualifier):
print(qualifier)
My goal is that when plugin is loaded, it reads the project folders and looks for specific files depending on the folder. As such, I need to access an external variable AS WELL AS the the WindowCommandClass
When doing print(WindowCommandClass)
I notice it populates all the methods with the self,window variables and everything works.
In theory I thought I could introduce variables as shown below
qualifier="qv"
print(WindowCommandClass.projectFolders(qualifier))
However, introducing arguments to any method on that class seems to destroy the self and window arguments from the WindowCommandClass. I've only been using python & sublime text api for a couple days, so I have no idea if I'm missing something small or attempting the impossible. Any ideas?
In case anyone is looking to pass values to a class in Sublime Text 3 plugin
Given a class that starts out
class GetWindow(sublime_plugin.WindowCommand)
def __init__(self,window):
self.window=window
def results(self)
return("just testing")
I was calling INCORRECTLY as
print(GetWindow().results())
What I had to do was supply the function with the class like this.
print(GetWindow(sublime_plugin.WindowCommand).results())
Now to get the variable as mentioned in original post I can do this
qualifier='qv'
results=SublimeID(sublime.window,qualifier).results()
Also modify class & methods to include the variable
def __init__(self,window,qualifier):
self.qualifier=qualifier
def results(self)
qualifer=self.qualifier
# You can now work with this external variable #