Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on creating an ArcGIS tool from a Python script I am writing. I am wondering if it is possible to have a checkbox parameter. Basically what I want to do is have a parameter where the user selects a feature class, then from the feature class the user will choose the field for the upper most layer in their model, then I want the user to be able to choose what layers they want the script to run on with a checkbox structure derived from the upper most layer field. Is this possible with python, and ArcGIS?

share|improve this question

A sample code for a script tool which will have a single check box. If a check box will be checked by a user, the tool will verify existance of a specified data file.

import arcpy
input_fc = r'C:\GIS\Temp\data_shp.shp'

    #getting the input parameter - will become a tool parameter in ArcGIS of Boolean type
    ischecked = arcpy.GetParameterAsText(0)

    #Important to convert the check box value to a string first.
    #Should be 'true' with the small case for 't',
    #not the 'True' as shown in the Python window in ArcGIS
    if str(ischecked) == 'true':
        arcpy.AddMessage("The check box was checked")
        result = arcpy.Exists(input_fc)
        #to return 'True' or 'False' depending on whether the data file exists
        #since it is a Boolean, important to convert it to a string

    else: #in this case, the check box value is 'false', user did not check the box
        arcpy.AddMessage("The check box was not checked")

Remember to add a tool parameter of Boolean data type when creating a new script tool in ArcGIS Desktop application. This parameter will be automatically shown as a check box when user runs the tool.

enter image description here

share|improve this answer
explaining that the boolean value equals 'true' for the if statement really helped me out. when i printed it to test it printed as 't'...thanks – gomapping Feb 28 '14 at 15:37
Glad for you! :) – Alex Tereshenkov Feb 28 '14 at 15:44

To see how to get a checkbox onto the dialog of a Python script tool try using some test code like this:

inputString = arcpy.GetParameterAsText(0)
inputBoolean = arcpy.GetParameterAsText(1)

arcpy.AddMessage("String set to " + inputString)
arcpy.AddMessage("Boolean set to " + str(inputBoolean))

Then when you add this script as a tool you will need two Parameters, the first of Data Type String and the second of Data Type Boolean.

share|improve this answer

Your Answer


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.