How can I programatically deactivate my python addin tool at the end of tool execution? In other words, I want to select my tool, click the map to execute my script logic, and then I want the tool to automatically deactivate or select a different tool by default. Is this possible? I'm currently working in ArcGIS 10.2, but I'm planning to move on to 10.4, if this matters.
Thanks, Dan. Yes, I have looked over the Help for Tool Class. I should also point out the content of this post: https://community.esri.com/thread/88371 . I was hoping for some more recent information or new insight on this topic.
It would be a good idea then to point that out to the documentation people at the bottom right of the page I sent. They are pretty good about addressing topics that are found to be in error or, in this case, not quite as advertised. A reference to the link you posted and your attempts in code might flag more than documentation changes since I doubt that this would be classified as a 'bug', perhaps a 'placeholder' for future enhancements... or at its worst a mis-representation.
I'm afraid you cannot deactivate programmatically What do you want to achieve by deactivating the add-in? Not to be able to use it in the same session? or next time you open ArcMap?
I can see situations when any deactivation of a tool would be useful (not just tied in to Arc* software). For example, to select something, when an on-click (new parlance?) has occured, the tool becomes deactivated until it is selected again. By deactivation, I would normally assume that one could specify the default tool as becoming active. But, I left behind the world of writing stuff for user interaction a long time ago, so maybe things are different now.
I'm wanting to deactivate the tool, as in making it no longer the active tool. I'm not trying to disable it, as in grayed out and unavailable. My reason for wanting this is that some of my other addin items will crash ArcMap if this tool is actively selected. Nothing ever crashes if the tool is NOT the active tool. So I'm just wanting to deactivate it as soon as the user has completed its task.
In short, this particular tool works perfectly on its own. My other addin items work perfectly on their own. But they don't play nice together if the tool is left active. The other items utilize a tkinter user input dialog (which I have read can be problematic with arcpy addins). I believe there is a problem when the tool is left active because both the tool and the tkinter items are looping as they wait for more user interaction. But again, everything works fine unless the tool is left active when the tkinter dialogs are launched (by a button).
Just to be precise – you are using a Tool Class, right? You want to deactivate it “as soon a user has completed its task” – is there is any mechanism the tool can be aware of when the task is done? It has to happen before the Tkinter dialogs are launched – how do you launch the Tkinter dialog? By clicking on another button or tool?