About input user with an Add-in script

2120
5
Jump to solution
10-28-2015 08:42 AM
SebastiánVega
New Contributor

Hi there, i'm learning python and make add-in tools for ArcGis 10.2, additional to this i connected  Visual studio 2013 python project with arcpy and works fine.

So i made some add-in tools and the output is okey, but now i want some guide for add input user when for example press the button of the tool or something like that.

Is possible to display a popup window or something like that? and the user can enter the requirements data (like shapes file path, coordinates, sizes, etc) and when press the "ok" button (for example) the script run with the new user input.

maybe is a noob question but certainly is better than search in the wrong way.

Please, give me some help to move forward to the next step

THANKS

pd: sorry about the grammatical errors

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor

I've not worked with python Addins much but as I understand they are for "actions in response to an event, or requires the use of the mouse to interact with the display".

If you want to create an interface that looks like a geo-processing tool so they can choose parameters, enter values and then something happens then you are looking at model builder or a python script tool.

Look at the Desktop Help for the topic "What is a Python addin?"

View solution in original post

5 Replies
DuncanHornby
MVP Notable Contributor

I've not worked with python Addins much but as I understand they are for "actions in response to an event, or requires the use of the mouse to interact with the display".

If you want to create an interface that looks like a geo-processing tool so they can choose parameters, enter values and then something happens then you are looking at model builder or a python script tool.

Look at the Desktop Help for the topic "What is a Python addin?"

DarrenWiens2
MVP Honored Contributor

Building on Duncan Hornby​'s suggestion, I think the idea is to build a geoprocessing tool and then open it in response to an add-in button click event. See here for opening tool dialogs through the pythonaddins module's GPToolDialog() function.

SebastiánVega
New Contributor

FIRST thanks for answer!!

but with the add-in python you can easily share your code with others.

So for example i did a Grid Index  Feature function, the tool take the shape and create a new shape with features (grid), after that with this new shape i have a python logical code which calculates with some restriction an array with 50 elements and their coordinates.

So the final process, python loop the Grid Index  Feature function (200 x 200 grid meters) for each element of the "array" and the result is saved in a gdb like:

element_01, element_02, etc....

But all this user input (the main shape, the distances, the size of the grid) are set on the code and the user can't change this values, so i want to be available to the user to choose another shape file (for example) and the distances of the grids, etc.

I don't know if with a python toolbox i can do that ...

hopes you can understand better now

0 Kudos
JamesCrandall
MVP Frequent Contributor

Darren Wiens posted 2 links that shows you what you will likely need in order to accomplish what you want.  I assume you need to open a specific Geoprocessing toolbox that you have created in order to collect parameters from the user, then perform the task and do this from the click of a button in your add-in:

class ButtonClass_OpenToolBoxName(object):
    """Implementation for EOCTools_addin.button_1 (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        pythonaddins.GPToolDialog(r'C:\FolderName\ToolboxName.tbx', 'ToolboxScriptName')

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
SebastiánVega
New Contributor

yeah

GPToolDialog, i looked about that function, thanks james, i will test

thanks all for your help

0 Kudos