in_txt = raw_input('Enter your value :')
Dear NobiirAhmer
I m workin with arcgis 10.7. I am trying to use your application.
I run arcpy.ImportToolbox(r"C:\0voltmp\PopUp.tbx") and works fine, the tool is imported but
when I run result = arcpy.PopupInputBox_popup("A message from popup box") no window pop up. Se picture below
can you help me. I dont kno why it not work. Thank you
Gabriel
Wow – that’s great. ☺
You can use a script tool as others have mentioned. But the piece of the puzzle that was missing for me until now, was how to pass the user input from the script tool back to the Add-In. I have just found a method of doing this at https://gis.stackexchange.com/questions/75691/accessing-the-output-of-a-python-script-tool-dialog-arcgis-10-1 .
In brief, you can call your AddIn python module and any of its classes/variables functions from your script tool. I have tested this and it works fine for me. In brief, in your script tool you can do it simply like this:
import arcpy, MyCustomTools_addin MyCustomTools_addin.findLayersButton.findLayers(arcpy.GetParameterAsText(0))
In this case my AddIn module is 'MyCustomTools_addin' and it has a button with the id 'findLayersButton' (note that this is the instantiated object, or id, not just the class name). This class has a function called 'findLayers()'.
I simply pass the only parameter from the tool to this AddIn class function (which then adds the layers to the map in a new layer group called "Search Results").
This is still not ideal, as the script tool dialogue stays on screen when it completes (which is good in most cases). I would prefer the script tool to disappear as soon as it has run (the user can configure this to happen, but then that would happen for all script tools, not just for this one).
I also like to display/log more useful information in my script tools. So in my tool I actually do it more like what is below. For my AddIn, the output of the function is simply a list of layers that match the string entered by the user. So the tool then displays the output in it's log window with AddMessage().
import arcpy, MyCustomTools_addin results = MyCustomTools_addin.findLayersButton.findLayers(arcpy.GetParameterAsText(0)) arcpy.AddMessage("\n\n\nRESULTS:\n\n{}\n\n".format("\n".join(results)))
http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/searchcursor-class.htm
Nobbir's second link, I believe. I know the system has had error with a few links lately.....may nee to cut and past above.
10.2 version ArcGIS Help (10.2, 10.2.1, and 10.2.2)
or http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000 if cut and past needed.
Thanks. I'm using arcgis10.2 . I don't know if it's because of me or my link but the second link you share return an error. I'm Going to wait to take a look to examples but i think you your reply is more helpfull Thann expected. Hope it's possible to tag people on topics because i have other threads for what i would have your help
William McLay,
Download the ZoomToFeature Python add-in from here:
http://www.arcgis.com/home/item.html?id=e753f3287f4a46c98c60e3e5c6a21463
Unzip the download - you'll see a folder named Install - there is a word document inside that folder. The doc describes how to use the add-in.
Hi @steve kenneth, which version of ArcGIS you are using? 10.1 or later? If so then you can use arcpy.da.SearchCursor to step through data row by row as shown below. If you are on 9.3 or earlier then use arcpy.SearchCursor instead (see documentation for sample code). Consult this topic more details:
Accessing data using cursors—Help | ArcGIS for Desktop
This topic contains code examples for arcpy.da.SearchCursor:
SearchCursor—Help | ArcGIS for Desktop
There is an argument named where_clause - set it in a similar way you'd in a SQL expression. The above topic has examples.
William, you may want to fork this to a new question since the main is answered....might get more response. You can mention this one as related. Also, check out Posting Code blocks in the new GeoNet
I am attempting to ask the user for a "proposal number" and simply zoom in on that proposal. I can call the Pop-Up Box and enter the value for the "proposal". But that value is not being passed into "SelectByAttribute_management" (see code below). Python says "AttributeError 'module' object has no attribute". Any help would be appreciated!
Thank You.
#Importing Modulesimport arcpy
#Call PopUpBoxtry: arcpy.ImportToolbox(r"F:\Data\Arcadwin\Toolboxes\PopUp.tbx") result=arcpy.PopupInputBox_popup("A message from popup box") in_val=result.getOutput(0) print in_val.upper()
except arcpy.ExecuteError: print arcpy.GetMessages(2)
except Exception as ex: print ex.args[0]
#Define WhereClauseWhereClause = '"MCPC_Num"' + "='" + str(in_val) + "'"
#Find the layermxd=arcpy.mapping.MapDocument("CURRENT")df=arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
#Select by Attributesarcpy.SelectByAttribute_management("Year 2015 Proposals", "NEW_SELECTION", WhereClause)
#Zoom to Selectiondf.ZoomToSelectedFeatures()
#Refresharcpy.RefreshActiveView()
Hi. Thanks to Mr Nobbir for the zipped file. I'm searching for something like that more than a year
I would create an customized tool for cadastral search. I would to know how set this script to search a value in shapefile table, to return a message if the inputs value hasn't been found, or automaticaly sélect thé feature if the user inputs exist.
Thanks before
Use a combobox to take the input. Make sure set the combobox's editable property to true. Write your code inside the OnEnter event of the combobox.
All I get back is "A Message from popup box" Which is the string going in. Nothing ever pops up.
Why isn't Tkinter supported? I think it should be.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.