<?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: Python Add-In User Input in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734263#M56923</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But will Tkinter be packaged with the add-in when I distribute it? I distribute my add-ins to other people and I don't want them to have to install additional libraries/interfaces such as Tkinter (and in some cases they aren't allowed to).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Aug 2012 19:26:28 GMT</pubDate>
    <dc:creator>JustinShepard</dc:creator>
    <dc:date>2012-08-21T19:26:28Z</dc:date>
    <item>
      <title>Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734261#M56921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was so excited to see that there is now a way to create add-ins using Python. However, now that I've got my add-in created and I'm trying to edit the script I noticed that user input still isn't fully supported. There are a few options for getting input, &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/The_pythonaddins_module/014p00000021000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/The_pythonaddins_module/014p00000021000000/&lt;/A&gt;&lt;SPAN&gt;, but I need to prompt my users to enter different values (such as text or numbers). As expected input and raw_input still don't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to get text and numbers from the user? If not will ESRI be adding this functionality to the pythonaddins module soon. Unless I can get full user input support this option for creating add-ins will rarely, if ever, be used by me.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 17:07:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734261#M56921</guid>
      <dc:creator>JustinShepard</dc:creator>
      <dc:date>2012-08-21T17:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734262#M56922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use Tkinter GUI package to create user interface and get user inputs. You can create a class with an arcpy and user inputs properties as properties and do all geoprocessing based on user inputs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tkinter references can be found here &lt;/SPAN&gt;&lt;A href="http://docs.python.org/library/tkinter.html"&gt;http://docs.python.org/library/tkinter.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 17:48:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734262#M56922</guid>
      <dc:creator>BryanTruong</dc:creator>
      <dc:date>2012-08-21T17:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734263#M56923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But will Tkinter be packaged with the add-in when I distribute it? I distribute my add-ins to other people and I don't want them to have to install additional libraries/interfaces such as Tkinter (and in some cases they aren't allowed to).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 19:26:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734263#M56923</guid>
      <dc:creator>JustinShepard</dc:creator>
      <dc:date>2012-08-21T19:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734264#M56924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to use arcpy parameter like you would in a python toolbox?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2012 15:50:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734264#M56924</guid>
      <dc:creator>JustinShepard</dc:creator>
      <dc:date>2012-09-11T15:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734265#M56925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;But will Tkinter be packaged with the add-in when I distribute it? I distribute my add-ins to other people and I don't want them to have to install additional libraries/interfaces such as Tkinter (and in some cases they aren't allowed to).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tkinter is a standard library, anyone with Python installed will have access to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a way to use arcpy parameter like you would in a python toolbox?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Input parameters should be able to be handled the exact same way as a python toolbox.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2012 15:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734265#M56925</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-09-11T15:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734266#M56926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Tkinter will not work. It will crash everytime. Tkinter for some reason, it wasn't specified why, does not play well with the ArcGIS framework. This was mentioned in the Python Addin Seminar &lt;/SPAN&gt;&lt;A href="http://training.esri.com/gateway/index.cfm?fa=catalog.webCourseDetail&amp;amp;CourseID=2485"&gt;http://training.esri.com/gateway/index.cfm?fa=catalog.webCourseDetail&amp;amp;CourseID=2485&lt;/A&gt;&lt;SPAN&gt;. There is a work around using wxPython GUIs but it looks like it might still be a little unstable. &lt;/SPAN&gt;&lt;A href="http://betablogs.esri.com/beta/arcgis/2012/05/03/custom-wxpython-guis-an-approach-for-arcgis-10-1/"&gt;http://betablogs.esri.com/beta/arcgis/2012/05/03/custom-wxpython-guis-an-approach-for-arcgis-10-1/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2012 15:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734266#M56926</guid>
      <dc:creator>JohnDye</dc:creator>
      <dc:date>2012-09-12T15:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python Add-In User Input</title>
      <link>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734267#M56927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Tkinter doesn't play nice with Python add-ins, but one way to work around it is to launch dialogs in a subprocess and then read the output from the shell.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, if you needed an Open File dialog with filtering, you might put the following script named as "file_open.py" in your add-in's install directory:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# file_open.py

import Tkinter
import tkFileDialog
import sys

# Get command line arguments
args = sys.argv
args_len = len(args)

# Create parent window and hide it from view
root = Tkinter.Tk()
root.withdraw()

# Generate dialog options
options = {}
options['parent'] = root
if args_len == 2:
&amp;nbsp;&amp;nbsp;&amp;nbsp; options['title'] = args[1]
elif args_len == 3:
&amp;nbsp;&amp;nbsp;&amp;nbsp; options['title'] = args[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; options['initialdir'] = args[2]
options['multiple'] = False
options['filetypes'] = [('Special file','*.special'),('All files','*')]

# Show dialog
file_path = tkFileDialog.askopenfilename(**options)

# Destroy parent window
root.destroy()

# Print result
print file_path&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, use the following inside your add-in script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os
from subprocess import Popen, PIPE

def open_file_dialog(dialog_title, default_dir=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp; file_open = "file_open.py"
&amp;nbsp;&amp;nbsp;&amp;nbsp; file_path = os.path.join(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.path.dirname(os.path.abspath(__file__)), file_open)
&amp;nbsp;&amp;nbsp;&amp;nbsp; file_arg = [file_path, dialog_title]
&amp;nbsp;&amp;nbsp;&amp;nbsp; if default_dir is not None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file_arg.append(default_dir)
&amp;nbsp;&amp;nbsp;&amp;nbsp; proc = Popen(file_arg, shell=True, stdout=PIPE, bufsize=1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; stdoutdata, stderrdata = proc.communicate()
&amp;nbsp;&amp;nbsp;&amp;nbsp; proc.terminate()
&amp;nbsp;&amp;nbsp;&amp;nbsp; return stdoutdata.strip()

file_path = open_file_dialog("Open File")
if arcpy.Exists(file_path):
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you need text or numeric input, you can use other Tkinter window functions similarly to build the appropriate dialog.&amp;nbsp; In general though, you might think whether you can rework your add-in to function without the input or whether the functionality you are trying to implement would better exist in a toolbox.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:18:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-add-in-user-input/m-p/734267#M56927</guid>
      <dc:creator>AdamWehmann</dc:creator>
      <dc:date>2021-12-12T07:18:29Z</dc:date>
    </item>
  </channel>
</rss>

