tk filesave dialog triggers unexpected destroy event

Discussion in 'Python' started by John Hunter, Jul 9, 2006.

  1. John Hunter

    John Hunter Guest

    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()
    John Hunter, Jul 9, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve E.
    Replies:
    0
    Views:
    313
    Steve E.
    Nov 11, 2003
  2. Rolf Barbakken
    Replies:
    1
    Views:
    2,466
    sumu1234
    Sep 3, 2006
  3. Ook
    Replies:
    2
    Views:
    312
  4. Tom Szabo
    Replies:
    10
    Views:
    202
    Grant Wagner
    Nov 26, 2004
  5. libsfan01

    iframe reloading triggers event

    libsfan01, Sep 22, 2006, in forum: Javascript
    Replies:
    0
    Views:
    97
    libsfan01
    Sep 22, 2006
Loading...

Share This Page