3

The following script works great from the command line but crashes from the pythonaddin:

import Tkinter

import tkFileDialog
root = Tkinter.Tk()
root.withdraw()
pathtest = tkFileDialog.askopenfilename()
print pathtest

pathtest = pythonaddins.OpenDialog('Open Item', True) does not work for me because it suppresses filetypes that I need to see (pdf).

I know this is a duplicate question but I just joined the site and could not comment on other posts.

5
  • 1
    Using Tkinter or any other python gui-library is not supported for python-addins. The only supported option is using C#/arcobjects instead.
    – warrieka
    Commented Apr 27, 2015 at 15:07
  • Anyone have an idea of how to use the pythonaddins.OpenDialog() without it suppressing file extensions. Commented Apr 27, 2015 at 16:14
  • pythonaddins.OpenDialog is only for browsing for spatial datasets. You could try PyQT per the suggestion by Jason Scheirer (an ESRI software developer) in the question you linked to.
    – user2856
    Commented Apr 28, 2015 at 0:52
  • Will I have the same issue with PyQT that I had with Tkinter? Commented Apr 28, 2015 at 17:30
  • @Brad No idea, never tried it. But given that the suggestion was made by an ESRI employee (who I understand developed much of the ArcGIS python stack), I suggest you give it a go.
    – user2856
    Commented Apr 29, 2015 at 4:13

2 Answers 2

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

0

You could try using native win32 dialogs. You'd need to have pywin32 installed first (pip installable version is pypiwin32), then you could do something like:

import win32ui
dlg = win32ui.CreateFileDialog(1, ".pdf", "Default File Name.pdf", 
                               0, "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*|")
dlg.DoModal()
print dlg.GetPathName()
del dlg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.