1

Using ArcGIS 10.4 for Desktop, I am, for the first time, trying to work with a Python Toolbox (*.pyt).

According to Creating a new Python toolbox documentation I am trying to edit The Python toolbox template, but it seems not working.

I have edited the template like this:

import arcpy


class StackProfile(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "TOOLBOX LABEL PROPERTY"
        self.alias = "TOOLBOX ALIAS PROPERTY"

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


class SP(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Stack Profile for Multiple Elevations"
        self.description = ""
        self.canRunInBackground = False

I tried to rename the toolbox name, label and alias. But in toolbox Properties it seems only the name is changed not label, or alias or even not the tool name.

I have a screen shot of my properties window: pythontoolbox Properties Window

It also did not change the tool name.

What could be the possible reason for this problem?

1

You have renamed the Toolbox class to StackProfile.

You can rename the original Tool class, and any copies of it that you make within the *.pyt to create more tools but a Python Toolbox must always have that Toolbox class which is used to define the toolbox.

If you want your toolbox to be named StackProfile then your file should be named StackProfile.pyt but that first class must be named Toolbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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