By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,548 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,548 IT Pros & Developers. It's quick & easy.

tk filesave dialog triggers unexpected destroy event

P: n/a

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


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)
def callback(*args):
print 'called callback'
window.bind("<Destroy>", callback)

Jul 9 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.