I have been developing a few python addins and I'm just wondering what is the best way to re-compile the addin anytime I edit the script.
Currently, if I make an edit to the script, it seems like I have to
- Close ArcMap
- Go to My addin folder and double click the 'makeaddin' python file
- Double click the 'Python Addin File
- Restart ArcMap for the changes to come into effect
If I don't do these steps, then the edits aren't recognized. This gets pretty annoying and time consuming when I want to place maybe a simple print line somewhere or I do a small edit just to test a result.
Is there a better way of doing this?
Best Answer
You can use the builtin
reload
function in python to automatically reload your module. What you can do is something like this:where
hook()
is what's called by ArcMap andmymodule
is the module you're editing between invocations. You may have to editsys.path
to include the path of the module you're editing so thatimport mymodule
does not fail. Or include the directory insite-packages
(maybe usingpython setup.py develop
).