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.

I'm trying to create some Python Toolboxes for our ArcMap application (e.g. MyTool.pyt)

I can see that the help text is defined with the classes self.description attribute.

However, once I run the program, and click into any of the parameter fields, the help/description text goes empty. I would like to be able to provide the description field for each parameter. How is this accomplished?

EDIT: After some responses, I see that via the 'Item Description' right-click context menu there are many fields that may be populated. Is there a 'pythonic' way to do this? That is, just by embedding some attributes in the .pyt file classes?

For instance, in the .pyt toolbox definition you have the Toolbox class:

import arcpy

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "My Toolbox"
        self.alias = ""

        # List of tool classes associated with this toolbox
        self.tools = [MyNiceTool]


class MyNiceTool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "My Tool Class"
        self.description = """
A description that shows up in the help context side pane when the tool is launched.
        """
        self.canRunInBackground = True

    def rest_of_required_methods....

From the self.description string the Tool dialog help window will display this text. However, what I am wanting to do is have a 'description' embedded in my code for each parameter also, so that when the tool is launched, and the user clicks into a parameter field, the parameter description is shown. If I were to do this using the 'Item Description' method referenced in the replies below, I would edit the fields Dialog Explanation under the Syntax section for each parameter... I guess.

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

I can see that the help text is defined with the classes self.description attribute.

This is where you are going wrong. In the help page Documenting a tool in a Python toolbox it says:

For Python toolboxes, the documentation for the toolbox and tools are stored in .xml files that are associated with the toolbox and tools by name. The help for each tool will be stored in a separate .xml file.

This means that you cannot set help text from within the .pyt file itself. This makes sense when you consider that the help text is not plain ASCII but rich text that can include formatting, bullets, and images.

Fortunately, Python supports for reading and writing XML, so you should be able to dynamically edit the help text from a separate script.

share|improve this answer
    
Thanks for the link to the 'Documenting' help page.. I searched, but for some reason didn't come to that page. It would be nice if ESRI supported restructuredText. Then we could document the toolboxes from the code directly as one can using Sphinx. –  John May 14 '13 at 22:32
add comment

If I understand correctly, you want to add Help texts to your functions. That can be done by right-clicking your tool from the toolbox window and click Item description and then Edit at the top. It'll allow you to add a description for each parameter, which will show up in the help section when clicking the parameter.

If you are in Arcmap 10.0 (at least earlier SP's) you need to do this from the ArcCatalog window (browse to your toolbox) within Arcmap for it to work.

share|improve this answer
    
Thanks, this is helpful, and it seems to indeed be a solution. In fact, it opens up a whole new series of questions for me! I didn't realize about all of these 'Item Description' fields, as I've only worked with the toolboxes via the Python Toolboxs (.pyt) files in 10.1. Unfortunately, it is not quite what I was after, though... so I'm going to edit my question now. –  John May 14 '13 at 12:48
add comment

You can define messages for each parameter by following these steps:

  1. Open ArcCatalog and highlight the Script in the catalog tree
  2. Select the Description tab
  3. Click the Edit button
  4. Click the down arrow next to each parameter and type in a message
  5. Save edits by clicking the Save button

When a users clicks within a script parameter now they will see your message.

share|improve this answer
    
Thanks.. do you know where this information is then ultimately saved? Does it get written to the xml files that seem to be created in the folder where i place the .pyt file? –  John May 14 '13 at 13:02
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.