Python AddIn - Application Extension

608
2
Jump to solution
09-19-2017 07:37 AM
ChrisHolmes
Occasional Contributor III

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

0 Kudos
1 Solution

Accepted Solutions
ChrisHolmes
Occasional Contributor III

Ok, figured this one out. It seems that before the extension will work you actually have to load it from Customize > Extensions (duh!):

View solution in original post

2 Replies
ChrisHolmes
Occasional Contributor III

Ok, figured this one out. It seems that before the extension will work you actually have to load it from Customize > Extensions (duh!):

ChrisHolmes
Occasional Contributor III

One last note. Even though in the Python Add-In Wizard I did select `Load Automatically` for the extension.

It did not load the extension. It is listed in the Extensions list but is not being loaded automatically. I checked it out with both Windows 7 and 10, no difference.

0 Kudos