Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • tkFileDialog bug on windows

    1 answers - 895 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi everyone,
    I may have found a strange bug with tkFileDialog, and I'm wondering if
    anyone has a workaround for the problem. It happens when you have a
    button (or any other clickable widget) directly behind the
    askopenfilename dialog box and double click on a file. The button
    (behind the open file dialog) gets clicked, when it shouldn't. It
    occurs with the code below (but only under windows).
    from Tkinter import *
    import tkFileDialog
    def cmd():
    print "button was pressed"
    parent = Tk()
    Button(parent, text = "hello", command = cmd, width=30, height = 10).pack()
    tkFileDialog.askopenfilename(parent=parent, title = "Double click on a
    file with the 'hello' button directly behind")
    parent.mainloop()
    Any ideas?
    Thanks!
    Fred
    Tutor maillist - Tutor (AT) python (DOT) org
  • No.1 | | 1424 bytes | |

    Fri, 2 Dec 2005 16:58:26 -0800
    Fred Lionetti <lordvader (AT) gmail (DOT) comwrote:

    Hi everyone,

    I may have found a strange bug with tkFileDialog, and I'm wondering if
    anyone has a workaround for the problem. It happens when you have a
    button (or any other clickable widget) directly behind the
    askopenfilename dialog box and double click on a file. The button
    (behind the open file dialog) gets clicked, when it shouldn't. It
    occurs with the code below (but only under windows).

    from Tkinter import *
    import tkFileDialog

    def cmd():
    print "button was pressed"

    parent = Tk()
    Button(parent, text = "hello", command = cmd, width=30, height = 10).pack()
    tkFileDialog.askopenfilename(parent=parent, title = "Double click on a
    file with the 'hello' button directly behind")

    parent.mainloop()

    Hi Fred,

    I don't have a windows box here to try it, so I can just guess.
    my linux box the list in the dialog responds to ButtonRelease events,
    but I think on windows tk uses native dialogs, and maybe these respond to ButtonPress events;
    if this is the case, it may happen that the ButtonRelease occurs *after* the dialog window
    has been destroyed, so the event gets delivered to the button in the parent window.

    Regards

    Michael

    Tutor maillist - Tutor (AT) python (DOT) org

Re: tkFileDialog bug on windows


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 9 =
QUESTION ON "Python"

EMSDN.COM