tk filesave dialog triggers unexpected destroy event

J

John Hunter

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top