AnsweredAssumed Answered

Python toolbox doesn't want to refresh

Question asked by CptGIS on Jun 15, 2015
Latest reply on Jul 8, 2015 by graeme

Hi, i got a problem with my python toolbox.


First, i have a toolbar (test_addin) with 3 buttons:


Button1 will activate Button2 and deactivate himself. Same thing for Button2.


"Go" will start a tool in a python toolbox.

This tool have a parameter object with a defaut value set to "1" or "2" depending on which button is activated.


The problem is: when i execute the tool, it work one time, but when i try to activate the other button, and then rerun the tool,

the defaut value for the parameter is not refreshing. I have to refresh the python toolbox manually to make it work.


Is there a way to make this work automatically?

Tank you!





import arcpy
import pythonaddins

class ButtonClass1(object):
    """Implementation for test_addin.button1 (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        button1.enabled = False
        button2.enabled = True
        gobutton.enabled = True

class ButtonClass2(object):
    """Implementation for test_addin.button2 (Button)"""
    def __init__(self):
        self.enabled = False
        self.checked = False
    def onClick(self):
        button2.enabled = False
        button1.enabled = True
        gobutton.enabled = True

class GoClass3(object):
    """Implementation for test_addin.gobutton (Button)"""
    def __init__(self):
        self.enabled = False
        self.checked = False
    def onClick(self):
        tbx = r"V:\mes documents\ArcGIS\AddIns\test\Install\Toolbox.pyt"
        tool = "Tool"
        pythonaddins.GPToolDialog(tbx, tool)


python toolbox:


import arcpy
import test_addin

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "Toolbox"
        self.alias = ""

        # List of tool classes associated with this toolbox = [Tool]

class Tool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        # First parameter
        param0 = arcpy.Parameter(
            displayName="Active button",

        if test_addin.button1.enabled == True:
            param0.value = "1"
        if test_addin.button2.enabled == True:
            param0.value = "2"

        params = [param0]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""

    def execute(self, parameters, messages):
        """The source code of the tool."""