Select to view content in your preferred language

Python Add-In does not report to python window

919
2
09-05-2013 02:48 AM
BenWin
by
New Contributor
Hi,

I just began to take a look at the Python Add-Ins. Simple tests with buttons and tools do work, after normal installation. But in my case the Add-Ins do not report any information to the python window (ArcMap 10.1). So the debugging as described in the ArcGIS Help ???guidebook??? by sending ???exceptions??? as well as using the ???print??? statement does not work at all.
Does anyone have an idea what the reasons could be?

Thanks for any help
Tags (2)
0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor
Can you post a code example of one of your python add-ins?
0 Kudos
BenWin
by
New Contributor
Here some code example...
Its just some GP Script tool dialog to open on one butten, some print command on another and the exmaple fishnet tool taken from arcGIS helpfile...

I also realised by using the makefile the images are not implemented so the addin only has 2KB and in beginning before populating with futher code it was something around 50kb

import arcpy
import pythonaddins

class ButtonClass1(object):
    """Implementation for TirolerV02_addin.btn1 (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        # Starts Hailtool Dialog
        print "Hailtool started"
        pythonaddins.GPToolDialog("C:\\BW_Workspace\\Toolbox_BW_V02\\Toolbox_BW.tbx", "HagelSchadensableitung")


class ButtonClass2(object):
    """Implementation for TirolerV02_addin.btn2 (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        print "hi"
        pass

class ToolClass1(object):
    """Implementation for TirolerV02_addin.tool1 (Tool)"""
    def __init__(self):
        self.enabled = True
        self.cursors = 3
        self.shape = 'Rectangle'

    def onRectangle(self, rectangle_geometry):
        """Occurs when the rectangle is drawn and the mouse button is released.
        The rectangle is a extent object."""

        extent = rectangle_geometry
        # Create a fishnet with 10 rows and 10 columns.
        if arcpy.Exists(r'in_memory\fishnet'):
            arcpy.Delete_management(r'in_memory\fishnet')
        fishnet = arcpy.CreateFishnet_management(r'in_memory\fishnet',
                                '%f %f' %(extent.XMin, extent.YMin),
                                '%f %f' %(extent.XMin, extent.YMax),
                                0, 0, 10, 10,
                                '%f %f' %(extent.XMax, extent.YMax),'NO_LABELS',
                                '%f %f %f %f' %(extent.XMin, extent.YMin, extent.XMax, extent.YMax), 'POLYGON')
        arcpy.RefreshActiveView()
        return fishnet
0 Kudos