The pythonaddins module
The pythonaddins module includes functions for supporting Python add-ins.
 Note:
Note:The pythonaddins module can only be used within a Python add-in. It cannot be used in stand-alone scripts or geoprocessing script tools.
| Function | Explanation | 
|---|---|
| OpenDialog({title}, {multiple_selection}, {starting_location}, {button_caption}) | Opens a dialog box to choose one or more GIS datasets. This function returns the full path of the dataset chosen. If multiple datasets are chosen, it returns a list of full paths. There is no filtering of the input datasets (for example, filter only for point feature classes). 
 | 
| SaveDialog({title}, {name_text}, {starting_location}) | Opens a dialog box to save data. This function returns the full path for the dataset to be saved. 
 | 
| GPToolDialog(toolbox, tool_name) | Opens a geoprocessing tool dialog box. 
 | 
| MessageBox(message, title, {mb_type}) | Shows a message box. This function returns a string value representing the message button pressed. 
 | 
| GetSelectedTOCLayerOrDataFrame() | Returns the selected layer or data frame from the table of contents. | 
| mb_type code | Message Box Type | 
|---|---|
| 0 | OK only | 
| 1 | OK/Cancel | 
| 2 | Abort/Retry/Ignore | 
| 3 | Yes/No/Cancel | 
| 4 | Yes/No | 
| 5 | Retry/Cancel | 
| 6 | Cancel/Try Again/Continue | 
This add-in button uses OpenDialog() to select a set of layer files and adds each layer to the selected data frame.
import arcpy
import pythonaddins
class AddLayers(object):
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        layer_files = pythonaddins.OpenDialog('Select Layers', True, r'C:\GISData', 'Add')
        mxd = arcpy.mapping.MapDocument('current')
        df = pythonaddins.GetSelectedTOCLayerOrDataFrame()
        if not isinstance(df, arcpy.mapping.Layer):
            for layer_file in layer_files:
                layer = arcpy.mapping.Layer(layer_file)
                arcpy.mapping.AddLayer(df, layer)
        else:
            pythonaddins.MessageBox('Select a data frame', 'INFO', 0)
This add-in button opens a geoprocessing tool.
import arcpy
import pythonaddins
class OpenGPTool(object):
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        pythonaddins.GPToolDialog(r'C:\MyTools\WaterStudy.tbx', 'GroundWaterYield')