<?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 Python Add-In Message Box interaction in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364356#M28797</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an add-in created, and it runs the tools as needed.&amp;nbsp; I would like to expand upon those tools to add some checks and balances with questions via the MessageBox function.&amp;nbsp; I can add message boxes just fine, but I'm trying to figure out how to script the *_addin.py file so that it does certain things based on the answer to the message box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a simple message box shown below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This creates the Yes/No message box, and works just fine on its own.&amp;nbsp; The problem now is that I'm not sure how to make Yes run the tool, while No stops the tool.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried the following with no luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.GPToolDialog(toolPath, 'ToolNameHere')&amp;nbsp; # toolPath is declared at the top...works without the MB&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mbAnswer = pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if mbAnswer = 'Yes':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.GPToolDialog(toolPath, 'ToolNameHere')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't seem to find anything online regarding how to use the user inputs to determine what to do when clicked.&amp;nbsp; I've found stuff about "Tkinter" and stuff similar, but nothing about the pythonaddins.MessageBox option.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:58:01 GMT</pubDate>
    <dc:creator>CoyPotts1</dc:creator>
    <dc:date>2021-12-11T16:58:01Z</dc:date>
    <item>
      <title>Python Add-In Message Box interaction</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364356#M28797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an add-in created, and it runs the tools as needed.&amp;nbsp; I would like to expand upon those tools to add some checks and balances with questions via the MessageBox function.&amp;nbsp; I can add message boxes just fine, but I'm trying to figure out how to script the *_addin.py file so that it does certain things based on the answer to the message box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a simple message box shown below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This creates the Yes/No message box, and works just fine on its own.&amp;nbsp; The problem now is that I'm not sure how to make Yes run the tool, while No stops the tool.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried the following with no luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.GPToolDialog(toolPath, 'ToolNameHere')&amp;nbsp; # toolPath is declared at the top...works without the MB&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mbAnswer = pythonaddins.MessageBox('Have you applied a definition query to all necessary layers?', 'Query check', 4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if mbAnswer = 'Yes':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.GPToolDialog(toolPath, 'ToolNameHere')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't seem to find anything online regarding how to use the user inputs to determine what to do when clicked.&amp;nbsp; I've found stuff about "Tkinter" and stuff similar, but nothing about the pythonaddins.MessageBox option.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:58:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364356#M28797</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-11T16:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In Message Box interaction</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364357#M28798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can already see an error, but I'm not sure if it'll fix the issue.&amp;nbsp; I'm only using one equals sign for mbAnswer = 'Yes'.&amp;nbsp; I'll give that a go.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2015 15:45:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364357#M28798</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-08-17T15:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In Message Box interaction</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364358#M28799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That didn't fix the issue.&amp;nbsp; All of my buttons (not just the one I'm modifying) show up as missing.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2015 15:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364358#M28799</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2015-08-17T15:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In Message Box interaction</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364359#M28800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the suggested route would be to make the definition query a required parameter...then the tool will fail if not done correctly...skip the message boxes altogether&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2015 17:01:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364359#M28800</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-17T17:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In Message Box interaction</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364360#M28801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That would definitely be ideal...but I don't know how to do that either, unfortunately.&amp;nbsp; I didn't know you could do that.&amp;nbsp; Is the methodology just a lookup of the definition query value and then an error message if it doesn't exist?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll add a little as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our feature classes have an initial query of "NetworkID IS NULL", so that whenever someone opens up our template map, they'll ideally see nothing.&amp;nbsp; They load the new project data, modify the fields in each feature class to match the NetworkID of their respective project, and then apply that definition query to each feature class to show only that NetworkID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that not everyone remembers to do this.&amp;nbsp; When they get to a certain point where they are to run a script that calculates/runs a lot of fields/tools, they're going to be doing so to a much wider range of data than intended. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since we already have a query applied to show NetworkID IS NULL, I am thinking something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;class tool_name(object):&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Implementation for addin_name_addin.button_tool_name (Button)"""&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self):&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.enabled = True&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.checked = False&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def onClick(self):&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for layer in layers:&amp;nbsp; # will define above&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.isFeatureLayer:&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.name == 'SampleLayer1'&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if layer.definitionQuery == """&amp;nbsp; 'NetworkID = 'SampleProject' """&amp;nbsp; # I would like to add two options (as shown, and if == none)&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pythonaddins.MessageBox('Modify the ' + SampleLayer + ' definition query and retry.', 'Incorrect Definition Query', 0)&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif:&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif:&amp;nbsp; # going through the rest of my feature classes with this level of elif's&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif:&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;pythonaddins.GPToolDialog(toolPath, 'ToolName')&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;I'm sure there are some issues with this, but it's just a stab in the dark.&amp;nbsp; I'm not sure if the placement of the tool run command is correct, and I'm not sure if my quoting around my definition query is correct either, just to name some that I have concerns with.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-message-box-interaction/m-p/364360#M28801</guid>
      <dc:creator>CoyPotts1</dc:creator>
      <dc:date>2021-12-11T16:58:03Z</dc:date>
    </item>
  </channel>
</rss>

