tkFileDialog.askopenfilename in python addin crashes ArcMap

1056
2
11-16-2019 08:07 AM
RemigijusPankevičius
New Contributor III

I tried to create an interactive tool that takes features selected in the active ArcMap view, allows user to pick a file and then attach it to selected features.

However, everything ends at tkFileDialog.askopenfilename() method crashing ArcMap. I have 10.5.1, but I managed to crash ArcMap in 10.7.1 on my colleagues machine.

Is that issue known, is that Python issue or ArcMap-s?


My example is here (crashes ArcMap):
GitHub - r-pankevicius/arcgis-addin-tool-py-template-with-selection-input: ArcGIS python add-in tool... 

0 Kudos
2 Replies
RemigijusPankevičius
New Contributor III

At the same time exactly the same code works as expected if I try it out in Python interactive window inside ArcMap:

>>>
... import Tkinter as tkinter
... import tkFileDialog
...
>>> def PickFileToAttach():
...     root = tkinter.Tk()
...     root.withdraw()
...     options = {
...         'parent': root,
...         'title': "Select a file to attach",
...         'multiple': False,
...         'filetypes': [('All files', '*')]
...     }
...     pathFile = tkFileDialog.askopenfilename(**options)
...     root.destroy()
...     return pathFile
...     
>>> PickFileToAttach()
u'C:/Users/***/Documents/ArcGIS-extensions.doc'
>>> PickFileToAttach()
''
>>> PickFileToAttach()
''
>>>

0 Kudos
RemigijusPankevičius
New Contributor III
0 Kudos