Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Can't Disable Python Addin Tool in Toolbar

$
0
0
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.

Code:

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

Any thoughts?
Code:

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


Viewing all articles
Browse latest Browse all 2485

Trending Articles