How can I programatically deactivate my python addin tool?

2382
23
08-31-2016 08:48 AM
GregoryAllspaw
New Contributor III

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.

Tags (2)
0 Kudos
23 Replies
DanPatterson_Retired
MVP Emeritus
0 Kudos
GregoryAllspaw
New Contributor III

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.

0 Kudos
DanPatterson_Retired
MVP Emeritus

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.

0 Kudos
GregoryAllspaw
New Contributor III

Please see also https://community.esri.com/thread/88371 .  I'm hoping for more recent info or new insight on this topic.

0 Kudos
NobbirAhmed
Esri Regular Contributor

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? 

0 Kudos
DanPatterson_Retired
MVP Emeritus

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.

0 Kudos
GregoryAllspaw
New Contributor III

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.

0 Kudos
GregoryAllspaw
New Contributor III

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).

0 Kudos
NobbirAhmed
Esri Regular Contributor

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?

0 Kudos