Select to view content in your preferred language

Python Add-in Module Help

1245
1
03-10-2017 08:55 AM
VishalShah2
Frequent Contributor

So I made a previous post on how to do a check in my addin module to see if the user using a custom tool was in an edit session. based on thoughtful discussions and research, I came to this conclusion for my script hoping for it to work. You're able to click on the tool but then nothing happens. I am not able to get to the Message Box and nothing happens with editor in terms of starting an edit session. Do I need to define my variables right after class or can I leave them in the portion. Any input and help would be greatly appreciated. How am I able to get my Message Box to pop up?

def onClick(self):

My entire code is the following:

class tool_project(object):
    """Implementation for Mapping_Tools_addin.tool_project (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        ws = r"workspace location"
        workspace = os.path.dirname(ws)
        editor = arcpy.da.Editor(workspace)


        if editor.isEditing == 'true':
            pythonaddins.GPToolDialog(toolPath, 'Tool Project')
        elif editor.isEditing == 'false':
            pythonaddins.MessageBox("You must be in an edit session to run this tool. If you wish to turn an edit session on, please click 'yes'. If you do not wish to turn an edit session on, please click 'no'.", "Turn Editor On?", 4)
            if mb_type == 'yes':
                editor.startEditing(False, False)
                pythonaddins.GPToolDialog(toolPath, 'Tool Project')
            elif mb_type == 'no':
                quit

mb_type is the third parameter in the pythonaddins.MessageBox module. More information regarding it can be found here.

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

See my reply in https://community.esri.com/message/671532-how-to-check-if-in-an-edit-session-using-python-and-arcpy?...‌ for dealing with the message box return results.

0 Kudos