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()


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to