So, the title doesn't make a lot of sense, but what I have going on is:
I have a PYT containing several tools.
I've added a class variable to one of the tools that calls a function to create a dictionary.
class Toolbox:
def __init__(self):
self.label = ""
self.alias = ""
self.tools = [tool1, tool2]
class tool1:
def createDict():
retDict = {}
return retDict
retDict = createDict()
def __init__(self):
self.label = ""
self.description = ""
def getParameterInfo(self):
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
pass
return
def postExecute(self, parameters):
return
The issue that I'm having is that the function (Lines 7-9) to create that class variable (Line 10) is called when I initialize the toolbox, not when I initialize that particular tool. This is making opening the toolbox take longer than it should, particularly given that I might want to use the other several tools and don't care about that dictionary getting created.
How can I make it so the function doesn't get called until I open that tool? I'm cool with waiting however long I need to; I just don't want to wait until I need to.
I'd be cool with like, adding it as a derived parameter in getParameterInfo(), but there isn't an option in Parameter data types to just use a python dictionary.
Any ideas? Thanks!