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...
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()
''
>>>
Oh, esri, seems I found a bug in ArcMap
See investigations: arcpy - tkFileDialog.askopenfilename in python addin crashes ArcMap, how to avoid it? - Geographic I...