4

I want to create a tool that list records of a field in the selection part and move some of records to the right pane.

How can i create the UI using ArcGIS and a Python script tool in a standard toolbox (TBX)?

I can create the selection part but not the sort and move buttons.

enter image description here

2
  • The answer to the question may be the same for both but are you using a standard (*.tbx) or Python (*.pyt) toolbox?
    – PolyGeo
    Oct 28, 2016 at 23:20
  • @PolyGeo I'm using *.tbx
    – BBG_GIS
    Oct 28, 2016 at 23:40

1 Answer 1

5

Unfortunately, this kind of GUI is not exposed via custom script tools. Your best choice would be to have a list of strings of MultiValue type and then let user tick the boxes besides the rows to choose records (here is how it can be generated).

The script tool source code:

import arcpy

in_fc = arcpy.GetParameterAsText(0)
in_field = arcpy.GetParameterAsText(1)
in_records = arcpy.GetParameterAsText(2)

for rec in in_records.split(';'):
    arcpy.AddMessage(str(rec))

The ToolValidator class:

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parameter
    has been changed."""
    if self.params[1].value:
      fc = self.params[0].value
      field = self.params[1].value
      with arcpy.da.SearchCursor(fc,field.value) as cur:
        self.params[2].filter.list = [row[0] for row in cur if row[0] is not None]
    return

The GP GUI:

enter image description here

Alternatively, if your end users are savvy enough, you could provide them with an input parameter of SQL Expression type which has the Obtained from property that makes it possible essentially to replicate the Select By Attributes dialog box in ArcMap.

1
  • @wetland, thanks for accepting and upvoting. Did it work for you to have the multivalue list? Otherwise, there are some options to use the win32api windows or something similar some pyqt to have own GUI outside of ArcGIS. Oct 31, 2016 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.