leoquig

Can't Disable Python Addin Tool in Toolbar

Discussion created by leoquig on Mar 13, 2014
Latest reply on Mar 13, 2014 by leoquig
I can't get this code to grey out googletool when I switch to layout view.

I have watched the video copied the example code in the help files and read about it. I must be missing something.

I also tried to with print "Change" after def activeViewChanged(self): but nothing appeared in the python prompt in Arcgis when i switched from data view to layout view.

My googletool wont work in data view so I wanted to disable it.

Caption: Google Maps
Class Name: googlemaps
ID:My_addin.googletool


Any thoughts?
class activeview(object):
    """Implementation for MY_addin.extension24 (Extension)"""
    def __init__(self):
        # For performance considerations, please remove all unused methods in this class.
        self.enabled = True
    def activeViewChanged(self):
        mxd = arcpy.mapping.MapDocument('current')
        active_view = mxd.activeView
        # tool1 is the tool ID (without the namespace prefix)
        if active_view == 'PAGE_LAYOUT':
            googletool.enabled = False
        else:
            googletool.enabled = True
        arcpy.RefreshActiveView()
        return

Outcomes