my problem is that I have a GUI made in tkinter that plots some maps and info and that part works good, but when I try to close the program with the X button of the window, the process is still running and I have to kill the process with the stop button, as read in this question they recommend to run in CMD, I did it on windows and check the task manager and after closing the program the process still continued, what can i do to fix that? Here is the structure of the script:
#This is some figure where i plot the maps
#marco de imagen principal
f = plt.figure(figsize=(3,3))
axe = f.add_subplot(111)
#axe = f.add_subplot(111)
#plt.axis('off')
axe.format_coord = lambda x, y: ''
#marco de ploteo de mapa
figu=plt.Figure(figsize=(2,2))
#ploteo=figu.add_subplot(111)
ploteo=figu.add_axes([0, 0, 1, 1])
ploteo.format_coord = lambda x, y: ''
plt.axis('off')
Class Inicio(tk.Tk):
def __init__(self, *args, **kwargs):
#I initialize all the menu, labels, variables and canvas and some other functions
def libro(self):
def onpress(self,event):
.
.
.
and more funtions
ex = Inicio()
ex.geometry("1280x720")
ex.mainloop()
Maybe the problem has to do with the plot?
Have you tried including a protocol to handle closing on the X
button?
import tkMessageBox as tmb
def __init__(self, *args, **kwargs):
# All your stuff
self.protocol('WM_DELETE_WINDOW', self.close_app)
def close_app(self):
if tmb.askokcancel("Close", "Are you sure...?"):
self.destroy()
This assumes that self.destroy()
is applied to your root
TKinter frame via ex.mainloop()
since it is your outermost call. self.destroy()
on the frame created by ex.mainloop()
will end the mainloop()
for root
as well.