<?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: ArcPy and Tkinter in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519444#M17229</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; What I would like to achieve is create a simple form allowing the user to set some parameters using dropdown controls, textbox, checbox, etc. along with buttons. This form would then run my ArcPy script after user clicked "Run". &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Geoprocessing script tool framework is an excellent mechanism to do so. If you let me know what type of values (data) you want for your GUI controls (dropdown, textbox, checkbox &amp;amp; buttons) I can provide you links to help topics to get it done. Alternatively, you can email me at &lt;/SPAN&gt;&lt;A href="mailto:&amp;quot;nahmed@esri.com&amp;quot;" rel="nofollow"&gt;nahmed@esri.com&lt;/A&gt;&lt;SPAN&gt; - we'll post the summary once something is figured out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Mathews: thanks a lot for the update. I'll give another try.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 May 2012 15:16:56 GMT</pubDate>
    <dc:creator>NobbirAhmed</dc:creator>
    <dc:date>2012-05-25T15:16:56Z</dc:date>
    <item>
      <title>ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519435#M17220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to know if ArcPy currently supports executing scripts using Tkinter inside ArcMap, i.e directly from the Python Window or in the ArcToolbox (embedded)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I tried to display a simple "Hello World" form, ArcMap 10 crashed on me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Olivier&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 14:09:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519435#M17220</guid>
      <dc:creator>OlivierVoyer</dc:creator>
      <dc:date>2012-05-22T14:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519436#M17221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can see this example to get started on integrating ArcMap and Tkinter in scripting tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/gallery/file/Geoprocessing-Model-and-Script-Tool-Gallery/details?entryID=F0B54854-1422-2418-A0F6-37042FE94472"&gt;http://resources.arcgis.com/gallery/file/Geoprocessing-Model-and-Script-Tool-Gallery/details?entryID=F0B54854-1422-2418-A0F6-37042FE94472&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 18:36:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519436#M17221</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-05-22T18:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519437#M17222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@Mathew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The TkInter example in your link works outside of ArcMap - as a standalone GUI interface. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Olivier&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TkInter does not work from within ArcMap - it crashes Arcmap. The reason is TkInter's event loop does not work with ArcMap. By the way, what are trying to achieve through the GUI?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 22:30:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519437#M17222</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-05-22T22:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519438#M17223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The example I posted works in ArcMap as a script tool. I just used it yesterday.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 12:10:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519438#M17223</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-05-23T12:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519439#M17224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wow! Great - it works. Until now all my attempts to get TkInter work in ArcMap ended in crash. Thanks a lot. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any other example that you can share?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 15:39:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519439#M17224</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-05-23T15:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519440#M17225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No unfortunately, my independent forays into integrating tkinter and script tools also failed, so I rummaged around and found that example which works by integrating the widget into a frame tied to the script tool itself, or so it seems. Whoever wrote it is far more knowledgeable in tkinter than I.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I tried implementing tkinter myself first I would use the standard script function implementation, which doesn't seem to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
class MyApp(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self, root):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.root = root
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [...]
def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; root = Tk()
&amp;nbsp;&amp;nbsp;&amp;nbsp; myapp = MyApp(root)
&amp;nbsp;&amp;nbsp;&amp;nbsp; root.title("Export Tool")
&amp;nbsp;&amp;nbsp;&amp;nbsp; root.update()
&amp;nbsp;&amp;nbsp;&amp;nbsp; root.mainloop()
if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Implementing the widget in this manner seems to be the silver bullet, tying the widget to the application under the __init__ and then calling your widget creation and geoprocessing under those new sub-functions seems to be the way to go.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
class Application(Frame):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self, master=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Frame.__init__(self, master)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.grid()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.createWidgets(master)

&amp;nbsp;&amp;nbsp;&amp;nbsp; def createWidgets(self, master):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [...]
root = Tk()
app = Application(master=root)
app.master.title(Title)
app.mainloop()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:39:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519440#M17225</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T22:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519441#M17226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;WARNING: I saved and closed the map document that worked with Mathew's sample. Now, whenever I attempt to re-open that particular map document, it crashes &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Mathew: Thanks for following up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Olivier: officially, ArcPy does not support Tkinter inside ArcMap. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Olivier, I am interested about your need for using Tkinter in ArcMap. Could you please let me know what you are trying to do with a custom GUI? I would like to investigate why your workflow cannot be implemented with our current scripting framework. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 19:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519441#M17226</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-05-23T19:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519442#M17227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;WARNING: I saved and closed the map document that worked with Mathew's sample. Now, whenever I attempt to re-open that particular map document, it crashes &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is fairly odd. I haven't seen that behaviour in my tests. Did you try running an MXD doctor on it? Was it a fairly complicated MXD before you tried to tool or a new one? Have you tried creating a new MXD with just one simple layer with a few features, save that, run the tool, save and close the MXD then see if you can reopen it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I made a few modifications to the script, mainly to accept tool parameters and any data type.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Author:&amp;nbsp;&amp;nbsp; Jennifer (esri_id: jenn775)
# Created:&amp;nbsp; July 20, 2010
# Edits:&amp;nbsp;&amp;nbsp;&amp;nbsp; Mathew Coyle, May 24, 2012

from Tkinter import *
import arcpy

# SelectPopup.py sample Python script using Tkinter for a user interface
# User selects feature from list, code selects and zooms to feature

# Use in ArcMap by attaching script to a button for best results
# In ArcGIS 10, you can add scripts and models to buttons in the UI without using VBA.
# Create a Python script tool using this script and then
# see "Adding a custom tool to a menu or toolbar" in this help topic:
# http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002400000005000000.htm

Layer = arcpy.GetParameterAsText(0) # Layer
SelField =&amp;nbsp; arcpy.GetParameterAsText(1) # Field to Select
Title =&amp;nbsp; arcpy.GetParameterAsText(2) # Title (optional)

# Troubleshooting messages
#arcpy.AddMessage("Layer is "+repr(Layer))
#arcpy.AddMessage("Selection field is "+repr(SelField))
#arcpy.AddMessage("Title is " + repr(Title))

class Application(Frame):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self, master=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Frame.__init__(self, master)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.grid()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.createWidgets(master)

&amp;nbsp;&amp;nbsp;&amp;nbsp; def createWidgets(self, master):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.yScroll&amp;nbsp; =&amp;nbsp; Scrollbar ( self, orient=VERTICAL )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.yScroll.grid ( row=0, column=1, sticky=N+S )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.stList = Listbox (self, yscrollcommand=self.yScroll.set)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.stList.grid( row=0, column=0 )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.yScroll["command"] = self.stList.yview
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # populate list with choices, sorted ascending
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("CURRENT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.name == Layer:
&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; break
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # for large datasets where the selection field contains many blanks or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # non-unique values, you can create a summary table and set SelTable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # equal to it for faster creation of the selection dialog
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SelTable = lyr.dataSource
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(SelTable, "", "", SelField, SelField + " A")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldVal = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newVal = row.getValue(SelField)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #only add value to Listbox if it is not a duplicate
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if newVal &amp;lt;&amp;gt; oldVal:
&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; self.stList.insert( END, row.getValue(SelField) )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldVal = newVal
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #add selection and quit button
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.selButton = Button (self, text='Select', command=self.selectFeat)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.selButton.grid( row=0, column=2 )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.quitButton = Button ( self, text='Quit', command=master.destroy )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.quitButton.grid( row=1, column=2 )

&amp;nbsp;&amp;nbsp;&amp;nbsp; def selectFeat(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sel = self.stList.curselection()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myFeature = self.stList.get(sel[0])

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; def BuildQuery(table, field, operator, value=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; """Generate a valid ArcGIS query expression

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arguments

&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; table - input feature class or table view
&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; field - field name (string)
&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; operator - SQL operators ("=","&amp;lt;&amp;gt;", etc)
&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; "IS NULL" and "IS NOT NULL" are supported
&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; value - query value (optional)

&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; # Adds field delimiters
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qfield=arcpy.AddFieldDelimiters(table,field)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # tweak value delimeter for different data types
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type(value) == str:
&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; # add single quotes around string values
&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; qvalue = "'" + value + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif value == None:
&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; # drop value when not specified (used for IS NULL, etc)
&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; qvalue = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # numeric values are fine unmodified
&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; qvalue = value

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = "{0} {1} {2}".format(qfield,operator,qvalue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print repr(sql)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return sql.strip()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = BuildQuery(Layer, SelField, "=", myFeature)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(where)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION", where)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("CURRENT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for df in arcpy.mapping.ListDataFrames(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if df.name == mxd.activeView:
&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; df.zoomToSelectedFeatures()
&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; arcpy.RefreshActiveView()


root = Tk()
app = Application(master=root)
app.master.title(Title)
app.mainloop()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519442#M17227</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T22:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519443#M17228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for your answers! Is is much appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Matthew: I will git it a try! Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;@Olivier: officially, ArcPy does not support Tkinter inside ArcMap. &lt;BR /&gt;&lt;BR /&gt;Olivier, I am interested about your need for using Tkinter in ArcMap. Could you please let me know what you are trying to do with a custom GUI? I would like to investigate why your workflow cannot be implemented with our current scripting framework. Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cool, thank you. I suspected tkinter would not work inside ArcMap, but I just wanted to confirm... now I know!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I would like to achieve is create a simple form allowing the user to set some parameters using dropdown controls, textbox, checbox, etc. along with buttons. This form would then run my ArcPy script after user clicked "Run". Is there any alternative to tkinter to achieve that inside ArcMap?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2012 11:27:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519443#M17228</guid>
      <dc:creator>OlivierVoyer</dc:creator>
      <dc:date>2012-05-25T11:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519444#M17229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; What I would like to achieve is create a simple form allowing the user to set some parameters using dropdown controls, textbox, checbox, etc. along with buttons. This form would then run my ArcPy script after user clicked "Run". &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Geoprocessing script tool framework is an excellent mechanism to do so. If you let me know what type of values (data) you want for your GUI controls (dropdown, textbox, checkbox &amp;amp; buttons) I can provide you links to help topics to get it done. Alternatively, you can email me at &lt;/SPAN&gt;&lt;A href="mailto:&amp;quot;nahmed@esri.com&amp;quot;" rel="nofollow"&gt;nahmed@esri.com&lt;/A&gt;&lt;SPAN&gt; - we'll post the summary once something is figured out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Mathews: thanks a lot for the update. I'll give another try.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2012 15:16:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519444#M17229</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-05-25T15:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519445#M17230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've never heard about this "Geoprocessing script tool framework"... could you give me more details about this tool? Does it come in the base package of ArcMap?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 May 2012 12:27:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519445#M17230</guid>
      <dc:creator>OlivierVoyer</dc:creator>
      <dc:date>2012-05-28T12:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519446#M17231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please email me at &lt;/SPAN&gt;&lt;A href="mailto:&amp;quot;nahmed@esri.com&amp;quot;" rel="nofollow"&gt;nahmed@esri.com&lt;/A&gt;&lt;SPAN&gt; - let's figure it out first and then we'll post the outcome to this thread. Please let me know what data/values you'll use and how.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 May 2012 13:34:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519446#M17231</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-05-28T13:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519447#M17232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Please email me at&amp;nbsp;&amp;nbsp; &lt;A href="mailto:&amp;quot;nahmed@esri.com&amp;quot;" rel="nofollow"&gt;nahmed@esri.com&lt;/A&gt; - let's figure it out first and then we'll post the outcome to this thread. Please let me know what data/values you'll use and how.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't mind sending you an email, but why not keep exchanging through this forum, so that everybody can benefit from our discussion? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I need to achieve is pretty simple, yet not fully determined. I just want to pop up a simple form giving the user some control over what would be done by my script, without using script parameters. Let's say I want to give the user a choice in the middle of my algorithm, for example if I want to pop up a window with several choices dynamically populated. That would be a good example of what I'm trying to do.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 13:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519447#M17232</guid>
      <dc:creator>OlivierVoyer</dc:creator>
      <dc:date>2012-05-31T13:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519448#M17233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you want to run your algorithm from command line and want the user to interact in the middle of the algorithm then a Python GUI program is your only option. As Esri does not officially support any such GUI yet - this forum is the only option to get help &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the other hand, if the user will interact with your script through some GUI then script tool framework is a good option. The Tool Validator class mechanism will allow you to fill up options dynamically based on what selection is made in other parameters. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In case you want to explore the script tool mechanism, you can start here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_creating_script_tools/001500000006000000/" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_creating_script_tools/001500000006000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This topic elaborates how to dynamically update parameter choices: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Customizing_script_tool_behavior/00150000000t000000/" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Customizing_script_tool_behavior/00150000000t000000/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 15:41:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519448#M17233</guid>
      <dc:creator>NobbirAhmed</dc:creator>
      <dc:date>2012-05-31T15:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy and Tkinter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519449#M17234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! That answers my question perfectly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 15:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-and-tkinter/m-p/519449#M17234</guid>
      <dc:creator>OlivierVoyer</dc:creator>
      <dc:date>2012-06-01T15:52:28Z</dc:date>
    </item>
  </channel>
</rss>

