Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

A question has been brought to my attention. When working with a shapefile within either 10 or 10.1. Is it possible to create a python script or some sort of programming language to accomplish this task;

An attribute table consists of 3 columns with multiple rows. Is there a way to set a list for each column that may be used when clicking within each cell. I know this can be done within an edit session with domain and subtypes but can it be done just within the Attribute table itself. By way of scripting.

Reason, this would provide a streamline process for individuals who do not know much about ArcGIS and would save the process of an edit session and potential of misspellings and what not. The easy fix for a GIS person would be to just use Domains and Subtypes. But the question is, can it be done differently?

share|improve this question
    
Are you asking if you can incorporate a drop-down list within cells of the shapefile attribute table? –  Aaron Dec 21 '12 at 19:32
1  
Yes I am. and the drop-down list would be a set list of my own creation –  Hunt_Gregory Dec 21 '12 at 19:35
    
Also, would I have issues with portability of shapefile and or possible feature class with the Script being "inside"? –  Hunt_Gregory Dec 21 '12 at 20:05
    
I would be surprised if you could do this with Python. This sounds more like a .NET/C# ArcObjects task. I would think somwehere along the lines of "silently" initiating an edit session once the cell is clicked, becuase as far as i'm aware, you can't make edits on a cell by cell basis if you're not in an edit session. You can make edits to an attribute table outside of an edit session, but the edits are carried out at the column level (e.g. Field Calculator). –  dchaboya Dec 21 '12 at 20:05
1  
Why not just use domains and subtypes? That's what they're there for. –  Fezter Dec 21 '12 at 20:07
show 2 more comments

2 Answers

You will want to work with subtypes in a file geodatabase--you cannot create subtype definitions for shapefiles. Look at domains and subtypes on the ArcGIS help page to learn more. The following script from ArcGIS 10.0 help shows how to create subtypes programmatically:

# Name: ManageSubtypes.py
# Purpose: Create a subtype definition
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env

try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    env.workspace =  "C:/data/Montgomery.gdb"

    # Set local parameters
    inFeatures = "water/fittings"

    # Process: Set Subtype Field...
    arcpy.SetSubtypeField_management(inFeatures, "TYPECODE")

    # Process: Add Subtypes...
    # Store all the suptype values in a dictionary with the subtype code as the "key" and the 
    # subtype description as the "value" (stypeDict[code])
    stypeDict = {"0": "Unknown", "1": "Bend", "2": "Cap", "3": "Cross", "4": "Coupling",\
                 "5": "Expansion joint", "6": "Offset", "7":"Plug", "8": "Reducer",\
                 "9": "Saddle", "10": "Sleeve", "11": "Tap", "12": "Tee", "13": "Weld", "14": "Riser"} 

    # use a for loop to cycle through the dictionary
    for code in stypeDict:
        arcpy.AddSubtype_management(inFeatures, code, stypeDict[code])     

    # Process: Set Default Subtype...
    arcpy.SetDefaultSubtype_management(inFeatures, "4")

except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message
share|improve this answer
    
Thanks Aaron. Yea I am we'll versed in domain/subtypes just not in programming. I was given a question and I am just in the process of answering it. Thanks for your time and it is appreciated. I would prefer them to use Domains and Subtypes bc that's what they are meant for. –  Hunt_Gregory Dec 21 '12 at 23:48
add comment

It sounds like you want to create a custom data entry form with Python. This presentation by Mark Cederholm (also mentioned on this ESRI blog post which has their own example) discusses how this can be done in two different ways, one using Python Add-Ins at 10.1 and another using comtypes at 10.0 and earlier.

wxPython is the GUI framework they suggest, though be aware it is not supported by ESRI. If you are looking for a more mature GUI development path that is supported by ESRI you'll want to use either .NET or Java.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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