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?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Aug 30, 2016 at 8:37

1 Answer 1

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.

answered Aug 30, 2016 at 8:43
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.