Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > tk filesave dialog triggers unexpected destroy event

Thread Tools

tk filesave dialog triggers unexpected destroy event

John Hunter
Posts: 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)


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
iframe reloading triggers event libsfan01 Javascript 0 09-22-2006 09:37 AM
GridView _Sorting-event triggers twice every time user clicks on header Rolf Barbakken ASP .Net 1 09-03-2006 03:43 PM
When to destroy, when not to destroy Ook C++ 2 10-11-2005 02:11 AM
Is there an event when that triggers when the window is closing?? Tom Szabo Javascript 10 11-26-2004 02:45 PM
Prevent Netscape from appending .aspx during FileSave? Steve E. ASP .Net 0 11-11-2003 07:18 PM