r/gis•
beanz415

Does anyone have any experience with the Python Add-In Wizard?

Scripting/Code

I'm trying to make a button switch to disabled when I am in layout view, but have so far not been successful. I found this which pointed me in the right direction. Even following the steps there and the link the person who answered provided, I can't get mine to work. Here is my code:

class ActiveViewChange(object):
    """Implementation for quick_profile_addin.extension8 (Extension)"""
    def activeViewChanged(self):
        mxd = arcpy.mapping.MapDocument("CURRENT")
        active_view = mxd.activeView
        print active_view   # I only added this print state to see if it prints tot he python console in an mxd which it does not
        if active_view == 'PAGE_LAYOUT':
            qp_button.enabled = False
        else:
            qp_button.enabled = True
        arcpy.RefreshActiveView()
        return

class RunToolbox(object):
    """Implementation for quick_profile_addin.qp_button (Button)"""
    def __init__(self):
        self.checked = True
    def onClick(self):
        resp = pythonaddins.MessageBox('Run tool?', '', mb_type=1)
        if resp.lower() == 'ok':
           tb = <path to toolbox>
           name = 'toolbox.name'
           pythonaddins.GPToolDialog(tb, name)
        else:
            return

Posted Jun 16, 2017, 7:58 PM UTC

911
Loading comments…