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:
<SPAN class="keyword token">class</SPAN> <SPAN class="token class-name">MXDWatcher</SPAN><SPAN class="punctuation token">(</SPAN>object<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="string token">"""Implementation for PlanningTools_addin.mxdwatcher (Extension)"""</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">__init__</SPAN><SPAN class="punctuation token">(</SPAN>self<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># For performance considerations, please remove all unused methods in this class.</SPAN>
self<SPAN class="punctuation token">.</SPAN>enabled <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">openDocument</SPAN><SPAN class="punctuation token">(</SPAN>self<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#pass</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'open doc'</SPAN><SPAN class="punctuation token">)</SPAN>
pythonaddins<SPAN class="punctuation token">.</SPAN>MessageBox<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'open doc'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">closeDocument</SPAN><SPAN class="punctuation token">(</SPAN>self<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#pass</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'close doc'</SPAN><SPAN class="punctuation token">)</SPAN>
pythonaddins<SPAN class="punctuation token">.</SPAN>MessageBox<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'close doc'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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