tk filesave dialog triggers unexpected destroy event
John Hunter
jdhunter at ace.bsd.uchicago.edu
Sun Jul 9 15:43:43 EDT 2006
The following behavior surprised me. I have a Tk window and launch a
file save dialog from it. When the filesave dialog is finished, it
calls callbacks bound to the destroy event on the main window. Is
this expected, and can I avoid this?
To expose the problem, run this script and click the mouse button over
the application window. When the file save dialog is through, the
function "callback" is called, which I did not expect because I bound
this callback to the window destroy event.
Thanks for any advice. Using Tk 1.177
JDH
import Tkinter as Tk
from tkFileDialog import asksaveasfilename
def button(event):
fname = asksaveasfilename(
title='Save the figure'
)
window = Tk.Tk()
frame = Tk.Frame(window, width=500,height=500)
frame.bind('<Button-1>', button)
frame.pack()
def callback(*args):
print 'called callback'
window.bind("<Destroy>", callback)
window.mainloop()
More information about the Python-list
mailing list