<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: pythonaddins in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29174#M2260</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to add. If I have the following the zoom works fine and in this case the code doesn't wait as if its executing something. The message still doesn't print. If I didn't have the 3 lines of the selection code and just the message the addin just sits there looking like it's executing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import pythonaddins&lt;BR /&gt;import os.path&lt;/P&gt;&lt;P&gt;class ZoomCase(object):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for PNF_Zoom_Case_addin.button (Button)"""&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox("Hello","Check")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 May 2015 23:28:44 GMT</pubDate>
    <dc:creator>DonStazic</dc:creator>
    <dc:date>2015-05-27T23:28:44Z</dc:date>
    <item>
      <title>pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29167#M2253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I had posted this in Developers but it's been sitting there a couple of days with no response so I thought I'd try this space instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The answer is most probably glaring me in the face but I can't see it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I needed to activate a Python tool dialog through a Addin button and GPToolDialog looks like the answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is the script, can't be much simpler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pythonaddins
class ButtonClass1(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for Addin_Test_addin.button (Button)"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False
&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.GPToolDialog(r'C:\Users\stazicd\AppData\Roaming\ESRI\Desktop10.1\ArcToolbox\My Toolboxes\PVP Zoom.tbx','PVPZoom')&lt;/PRE&gt;&lt;P&gt;The button runs and after some time eventually zooms out to the full extent of the map document.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't be distracted by that zoom and think that my tool isn't working correctly. If I only have a&amp;nbsp; simple pythonaddins.MessageBox the same thing happens. It looks like the script isn't finding pythonaddins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The button does work if I only have code in onClick that doesn't have any pythonaddins so the setup of the button is OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To check I ran the above GPToolDialog command in ArcMap using the Python command line window, things worked as they should.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like I'm missing something in a set up somewhere. Any suggestions folks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Don&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(&lt;A href="https://community.esri.com/migrated-users/3355" target="_blank"&gt;Curtis Price&lt;/A&gt;​ formatted the code 5/15/2015)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29167#M2253</guid>
      <dc:creator>DonStazic</dc:creator>
      <dc:date>2021-12-10T21:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29168#M2254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using 10.3 and tested your code. I created a pythonaddin tool bar with a single button on it. The &lt;STRONG&gt;model&lt;/STRONG&gt; in my toolbox ran without a problem and like you it also ran from the python command line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I did notice by chance (as I had the python window open) is it threw up an error message before the actual model tool opened:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TypeError: GPToolDialog() takes at most 1 argument (2 given)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then tested out of curiosity a model with and without parameters, both opened with the same TypeError message appearing in the python command line window. I also tried one parameter like &lt;EM&gt;C:\temp\toolbox.tbx\mymodel&lt;/EM&gt; and it threw an error saying it was missing tool_name argument!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is not clear from your explanation is if the tool you are trying to open in the toolbox is a &lt;EM&gt;model&lt;/EM&gt; tool or a &lt;EM&gt;script&lt;/EM&gt; tool? May be this is an issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 10:52:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29168#M2254</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2015-05-14T10:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29169#M2255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Duncan for looking into that at depth, I'm looking into those.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You say that "The model in my toolbox ran without a problem", do you mean toolbar?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script tool when I run it from a toolbox under My Toolboxes works OK. The error message is interesting as GPToolDialog has two parameters.&amp;nbsp; &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000021000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000021000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 02:03:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29169#M2255</guid>
      <dc:creator>DonStazic</dc:creator>
      <dc:date>2015-05-15T02:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29170#M2256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I created a pythonaddin which contained a single toolbar with a single button. The onClick event is calling a model in a toolbox. Just like your code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;EM&gt;pythonaddins.GPToolDialog(r'C:\Users\stazicd\AppData\Roaming\ESRI\Desktop10.1\ArcToolbox\My Toolboxes\PVP Zoom.tbx','PVPZoom')&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your toolbox is &lt;STRONG&gt;PVP Zoom.tbx&lt;/STRONG&gt; and you are calling the tool &lt;STRONG&gt;PVPZoom&lt;/STRONG&gt;. But from this alone I cannot tell if you are calling a &lt;EM&gt;script&lt;/EM&gt; tool or a &lt;EM&gt;model&lt;/EM&gt; tool? In my test I was calling a model and it worked but was throwing that odd TypeError message in the python console for some reason...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in your reply above you now say it was a script tool (some python exposed as a tool). I'm wondering if it is to do with that. Try making a simple model and running your pythonaddin to call that. If that works (as it did in my case) we can at least say your pythonaddin code is correct and it's something to do with the script code that you are calling?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 08:30:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29170#M2256</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2015-05-15T08:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29171#M2257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ran into the &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;TypeError: GPToolDialog() takes at most 1 argument (2 given&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;error a while back which resulted in bug NIM089253. I was able to find a work around and get it to work.that worked and I posted it &lt;A href="https://community.esri.com/message/75339"&gt;Tip: Python Addin - getting custom tools/toolbox to work - GPToolDialog&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&amp;nbsp; If not, I may have a few more tips and suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 18:02:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29171#M2257</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-05-15T18:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29172#M2258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please excuse the meta...&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I had posted this in Developers but it's been sitting there a couple of days with no response so I thought I'd try this space instead.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In the future, &lt;A href="https://community.esri.com/migrated-users/22141"&gt;Don Stazic&lt;/A&gt; please consider using the Share button on the right side of the discussion page. Or just add an "@mention" like this &lt;A href="https://community.esri.com/space/2030"&gt;Developers&lt;/A&gt;&amp;nbsp; makes the post visible to more groups - but keeps all the comments in one page. Much better that way!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/392178"&gt;Share a post with a group&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 May 2015 05:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29172#M2258</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-05-16T05:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29173#M2259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone for their input, I've learnt some stuff and tried both Rebecca's and Duncan's ideas. I haven't been able to look at this over the past week or so but I'm back onto it now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't though been able to find a solution to my problem. The onClick event is being entered, that I'm sure of as I put in code that didn't use any pythonaddins and that worked. Three lines of code that just zoomed to selected features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried in onClick event just having the following line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox("Hello","Check")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similar to calling pythonaddins.GPToolDialog() the program just keeps running, no message appears, so the problem appears to be has pythonaddins been imported even though that statement is there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/space/2030"&gt;Developers&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 05:25:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29173#M2259</guid>
      <dc:creator>DonStazic</dc:creator>
      <dc:date>2015-05-27T05:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: pythonaddins</title>
      <link>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29174#M2260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to add. If I have the following the zoom works fine and in this case the code doesn't wait as if its executing something. The message still doesn't print. If I didn't have the 3 lines of the selection code and just the message the addin just sits there looking like it's executing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import pythonaddins&lt;BR /&gt;import os.path&lt;/P&gt;&lt;P&gt;class ZoomCase(object):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for PNF_Zoom_Case_addin.button (Button)"""&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; df.zoomToSelectedFeatures()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox("Hello","Check")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 23:28:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pythonaddins/m-p/29174#M2260</guid>
      <dc:creator>DonStazic</dc:creator>
      <dc:date>2015-05-27T23:28:44Z</dc:date>
    </item>
  </channel>
</rss>

