<?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: Run Python script from button on toolbar. in Python AddIns Questions</title>
    <link>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820544#M77</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if&amp;nbsp;I close the command window the menu closes......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 May 2019 18:55:16 GMT</pubDate>
    <dc:creator>DaleShearer</dc:creator>
    <dc:date>2019-05-09T18:55:16Z</dc:date>
    <item>
      <title>Run Python script from button on toolbar.</title>
      <link>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820542#M75</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking at my question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I learning Python as I go and have made some headway, so here is what I have now ran into.&amp;nbsp; &amp;nbsp;I have a Python script that creates a menu, I can run it from PyScripter and it all works.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a toolbar using the Python Add-In Wizard that contains a button that will be used to load/run/execute/display the menu.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want is to click the button, menu appears, then I work with the selections on the menu to work with the layers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I start ArcMap the toolbar is displayed with the button.&amp;nbsp; When I click the button I get a messagebox that I programmed in to make sure it works, one I clear the messagebox I get a quick flash on the screen that I cannot make out, and that is it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code for the button on the toolbar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import pythonaddins&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class btnOpenMenu(object):&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; self.enabled = True&lt;BR /&gt;&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; pythonaddins.MessageBox("Open Menu", "Layer Menu", 0)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; os.system('D:\Applications\Python\Open Menu.py')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried:&amp;nbsp; &amp;nbsp;os.system(r'D:\Applications\Python\Open Menu.py')&amp;nbsp; &amp;nbsp;which did not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2019 17:13:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820542#M75</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2019-05-09T17:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Run Python script from button on toolbar.</title>
      <link>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820543#M76</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, making progress, it now works, sorta.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changed os.system to&amp;nbsp;os.startfile(&lt;SPAN style="background-color: #ffffff;"&gt;'D:\Applications\Python\Open_Menu.py')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Now I get the cmd window (blank) with the heading: C:Python27\ArcGIS10.5\python.exe opening.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;The cmd window opens right up, then about 5-10 seconds later my menu is displayed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;So now both are open, so now I need to get the cmd window from opening.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2019 18:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820543#M76</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2019-05-09T18:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Run Python script from button on toolbar.</title>
      <link>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820544#M77</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if&amp;nbsp;I close the command window the menu closes......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2019 18:55:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820544#M77</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2019-05-09T18:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Run Python script from button on toolbar.</title>
      <link>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820545#M78</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the end:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;execfile("&lt;SPAN style="background-color: #ffffff;"&gt;D:\Applications\Python\Open_Menu.py")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;is what it took to open the menu.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="border: 0px;"&gt;import arcpy&lt;BR /&gt;import pythonaddins&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="border: 0px;"&gt;class btnOpenMenu(object):&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; self.enabled = True&lt;BR /&gt;&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; pythonaddins.MessageBox("Open Menu", "Layer Menu", 0)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; execfile('D:\Applications\Python\Open Menu.py')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2019 19:42:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-addins-questions/run-python-script-from-button-on-toolbar/m-p/820545#M78</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2019-05-09T19:42:23Z</dc:date>
    </item>
  </channel>
</rss>

