469,903 Members | 1,808 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

tk filesave dialog triggers unexpected destroy event


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()
Jul 9 '06 #1
0 1169

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by vvenk | last post: by
1 post views Thread by Michael Yanowitz | last post: by
reply views Thread by nicstel | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.