AnsweredAssumed Answered

Python AddIn - Application Extension

Question asked by cwholmes on Sep 19, 2017
Latest reply on Sep 20, 2017 by cwholmes

Hello,

 

I have some code that I want to execute when an mdx file opens/closes. I'm trying to do it through an application extension because I also have a python addin which will be used with these files, so figure it makes sense to use the extension also.

 

Before even trying to get my code working in the extension I just want to simply present a message via python addin messagebox and/or writing a message to the python window in arcmap. And basically this isn't working.

 

Here is the code I'm trying on open/close:

class MXDWatcher(object):
"""Implementation for PlanningTools_addin.mxdwatcher (Extension)"""
def __init__(self):
    # For performance considerations, please remove all unused methods in this class.
    self.enabled = True
def openDocument(self):
    #pass
    print('open doc')
    pythonaddins.MessageBox('open doc','title',0)
def closeDocument(self):
    #pass
    print('close doc')
    pythonaddins.MessageBox('close doc','title',0)

 

Something else I notice in the Python Add-In Wizard, the "Methods to Implement" do not stay checked after I "Save" and close the Python Add-In Wizard. I'm assuming this is fine and that the methods I check are only referenced once when the wizard saves and creates those code blocks in the .py file.

Any ideas on what I've got wrong here appreciated.

 

Thanks,

Chris

Outcomes