Javier
Javier

Reputation: 35

Closing window (exit button/command+w) does not quit mainloop (Python 3.6 - Tkinter)

I would like to stop program when I close window using click on window exit button or command/control+w. I thought it is automatically. High Sierra + Python 3.6 + Tkinter 8.6

import tkinter as tk
root = tk.Tk()
texto = tk.StringVar(master=root) 
texto.set("Un nuevo texto")

tk.Label(root, text="¡Hola mundo!").pack(anchor="nw")
label = tk.Label(root, text="¡Otra etiqueta!")
label.pack(anchor="center")
tk.Label(root, text="¡Última etiqueta!").pack(anchor="se")
label.config(bg="green", fg="blue", font=("Verdana",24))
label.config(textvariable=texto)

imagen = tk.PhotoImage(master=root, file="lena.png") 

tk.Label(root, image=imagen, bd=0).pack(side="left")

root.mainloop()

Upvotes: 1

Views: 431

Answers (1)

Zx4161
Zx4161

Reputation: 180

Run your code from IDLE(python 3.6 64-bit). Close button worked for me.

Upvotes: 1

Related Questions