Thanks for looking at my question.
I have a Python toolbar with a button that runs a Python script that displays a menu box. This is being ran through ArcMap. I open my mxd, display the menu, now I want to close it when I am finished and that is the problem.
I am calling:
def quit():
root.destroy()
to close the menu from a button command.
When I run the script in pyscripter and display the menu box and hit the close button it works.
When I have the menu box open in ArcMap and hit the close button I get the following error:
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.5\Lib\lib-tk\Tkinter.py", line 1542, in __call__
return self.func(*args)
File "D:\Applications\Python\Layers.py", line 49, in quit
root.destroy()
NameError: global name 'root' is not defined
The next issue I see is how to close the Python box when I close ArcMap.
Thanks for looking at my question.
Solved! Go to Solution.
Well, fixed this, I put root.destroy in the command on the Button and it closes the menu box when being ran from ArcMap.
Button(root, text='Close',width=20,bg='brown',fg='white', font="Arial 8 bold", command=root.destroy).place(x=39,y=272)
Well, fixed this, I put root.destroy in the command on the Button and it closes the menu box when being ran from ArcMap.
Button(root, text='Close',width=20,bg='brown',fg='white', font="Arial 8 bold", command=root.destroy).place(x=39,y=272)