I have a Python add-in that includes an extension. The only purpose if this extension is for some buttons in the add-in to be automatically enabled/disabled depending on if there are relevant layers in the current MXD's table on contents.
Therefore I need this extension to be loaded automatically when this add-in is installed.
AND I need this extension to be enabled right from the start.
In the config.xml, 'autoLoad' is set to 'true'. In the Python class, the __init__ function for the extension class includes:
self.enabled = True
However, when I install the add-in and run ArcMap, the extensions dialog shows the extension but NOT checked.
Now, I have found that if I run something like:
myExtension.enabled = True
Within the __init__ method of some other toolbar class (eg, one of the buttons), then the extension IS CHECKED in the extensions dialog! However, it doesn't actually work. If I then quit ArcMap and restart ArcMap, the extension works fine (presumably because it remained enabled from the previous run of ArcMap).
So I can get the desired behaviour ONLY if I do BOTH of the following ODD things:
- enable the extension in the class of some other add-in button
- launch, quit, launch ArcMap
Is it possible to get a Python add-in extension to automatically load and be enabled by default when the add-in is installed by any other means?