Hot answers tagged

6

Tkinter is not compatible with any version of Arcmap desktop. As a script you are running pure python, and not using the ArcMap desktop application at all, which is why you are seeing different behavior. Esri has determined that tkinter and Arcmap desktop conflict in their messaging designs and they will not resolve the conflict, so tkinter is not supported ...


4

Since you're using a python addin, you could use the pythonaddins.OpenDialog method. Slightly modified example based on the documentation: This add-in button uses OpenDialog() to select a set of layer files and adds each layer to the selected data frame. import arcpy import pythonaddins class AddLayers(object): def __init__(self): self....


4

Based on your feedback, I would recommend you target your optimization on the MXD you're attempting to load. MXD's can become bloated over time from storing geoprocessing and other information. Usually this isn't very noticeable, but if you're using the same MXD in production it could cause the slow down. While your MXD doesn't seem that large, you may ...


3

I think the trick to using tkinter in Python is to run it from an external module, that way it isn't competing with the GUI components from the pythonaddins module. I do not take any credit for the tkinter GUI portion, as it was my colleague who figured it out, but here is a sample. The GUI is dynamically created based on a list of text elements, and ...


3

I managed to figure this out... My code now iterates through feature classes, requests a field name, calculates fields, deletes unwanted fields. And then joins the left over fields to each other with a spatial join. I was stuck on adding the interactive tkinter dialog box in the first loop, and the delete field text at the end of the first loop. I still have ...


3

I'm not sure about how to do this in Python other than using ArcObjects directly through COM interop - hardly the most pleasant approach. It's much easier to do in .NET, though for simplicity you will want the SDK and that's not available for download - I believe it comes with ArcGIS Desktop install media? And definitely with an EDN licence, of course, but ...


2

Sounds like you are asking to use the pythonaddins module and GPToolDialog method? I've not used this before so can't really comment on it. A quick look on the ESRI GeoNet forum threw up various threads about this, I would recommend you read those first before you try anything.


2

Here's the update: I used tkFileDialog.askdirectory() to get the gdb name to set the workspace. Then I used arcpy.da.Walk() from the data access module to load the feature classes into an array. My next step would be, put a ttk combobox on the GUI and load feature classes into the drop-down of the combobox so users get to specify the feature class to do ...


2

This is an issue with Tk's event loop conflicting with ArcGIS. TK expects that it is the only GUI loop running in the process. The only real 'work-around' (and more of a band-aid in my opinion) I've seen for using Tk in ArcGIS would be to create a python script GP tool and disable running the script in process. This is detailed in Another GIS Blog post ...


2

Tkinter and Esri Python Addins do not play nice together. You can use Tkinter within scripting with Acrpy, but it will usually crash when implemented in an Addin. wxPython GUIs will work within an ESRI Addin. However these will require the end user of your Addin to have wxPython installed on their machine.


2

I've been working with the Python API for long, and tried to use the mapclient module it has, but Google Developers did that first approach and then dropped it (I could find some links related to that if you need). I don't think there is a way you can just "insert the map". You'll have to code it yourself. You could start with mapclient.py, but I can ensure ...


2

You have a typo in this part of your code: if arcpy.Exists(r'F:\MyProject\Assignment\folkore_shp.shp'): arcpy.Delete_management(r'F:\MyProject\Assignment\folkore_shp.shp') folklore is misspelled. Fix: if arcpy.Exists(r'F:\MyProject\Assignment\folklore_shp.shp'): arcpy.Delete_management(r'F:\MyProject\Assignment\folklore_shp.shp') Also, as ...


1

This may be a path problem. Consider trying this, check if the location of the module you want to import is in the PYTHONPATH and, if not, then set the PYTHONPATH as needed.


1

PyQT is another GUI builder option, see Q/A below. Developing GUI in Python for ArcGIS geoprocessing using PyQT/Tkinter/wxPython?


1

As commented by @PauloRaposo: [This m]ight be an Esri bug ... See this on Error 000229, about background processing being enabled: http://support.esri.com/technical-article/000012177. Your code works just fine for me in a Python console using one of my own shapefiles.


1

Based on the hint of Luke I use now a eventbutton with the following code: class ToolClass71(object): """Implementation for Python_Addins_addin.tool (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle ...


1

There is a base widget method called focus_force (see here) that will force focus to the specified application - this should capture user input. There is also a toplevel attribute called topmost which can be set (see here). After creating the window widget, you will need to call the method and set the attribute i.e.: window.focus_force() window....


1

It is technically possible to use Tkinter in arcpy / python addins using multiprocessing, but this is quite complicated and not supported or recommended by ESRI. They recommend using C# instead of python for GUI development. See this post and http://anothergisblog.blogspot.se/2013/07/python-add-ins-and-tkinter.html


1

If you place your Tkinter code into the tool validation part (Tool>Properties>Validation>Edit), around parameter initialization, you should be fine. However this is not an advised method due to architectural discordances. Still you can use Python add-ins as suggested in Recommendations about graphic interface for ArcPy/Python script and Trying to use Tkinter ...


1

I think the delay is caused by waiting for the license server. If you can, switch to a standalone license and compare the difference. I've noticed that at times, the checkout process can take some time. Since we know that's not the issue, try installing 64 bit geoprocessing: http://blogs.esri.com/esri/arcgis/2012/11/12/python-scripting-with-64-bit-...


1

I found a technique to do this described at Another GIS Blog under the title of Python Add-Ins and Tkinter: ArcGIS for Desktop does not support any python GUIs out of the box, but let's say we want to have a form pop-up anyway. ... One way to do this is to create a wx python instance at start up, which is create before the desktop python loop is ...


Only top voted, non community-wiki answers of a minimum length are eligible