This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tkinter askopenfilename doubleclick issue on windows
Type: behavior Stage: resolved
Components: Tkinter, Windows Versions: Python 3.5
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: gpolo, paul.moore, rapolas, serhiy.storchaka, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-02-21 21:07 by rapolas, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue26405.tcl serhiy.storchaka, 2016-02-24 10:40
Messages (5)
msg260640 - (view) Author: (rapolas) Date: 2016-02-21 21:07
Issue is that doubleclick passes a click down to a parent window, and if it happens that you doubleclicking to select a file directly above some button, that button gets pressed. Here is the code to demonstrate this issue:

import tkinter as tk
from tkinter import filedialog, ttk

class MainWindow(ttk.Frame):
    def __init__(self, root, *args, **kwargs):
        super().__init__(root, *args, **kwargs)
        self.pack()
        btnoptions = {'expand':True, 'fill': 'both'}
        btn = ttk.Button(self, text='Select', command=self.ask_openfile)
        btn.pack(**btnoptions)

    def ask_openfile(self):
        filename = filedialog.askopenfilename()
        return filename

if __name__=='__main__':
    root = tk.Tk()
    root.geometry('600x300')
    MainWindow(root).pack(expand=True, fill='both', side='top')
    root.mainloop()

I observed the same behavior on two different computers, one running win10, another win7, both using the latest python 3.5.1 installation from python.org
msg260710 - (view) Author: (rapolas) Date: 2016-02-23 08:19
Just tried this on Python 2.7.11 and the issue is not present.
msg260785 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-24 10:40
Can't reproduce the bug on Linux.

Try to run pure Tcl/Tk script (install ActiveTcl and use the "wish" command). If the bug is reproduced, this is Tk bug.
msg260786 - (view) Author: (rapolas) Date: 2016-02-24 11:02
I tried on Linux as well, issue wasn't present. Attached tcl script has the same behavior.

And I found this already reported on tk tracker:

https://core.tcl.tk/tk/tktview?name=faf37bd379
msg260790 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-24 11:08
Thus this is not Python bug.
History
Date User Action Args
2022-04-11 14:58:27adminsetgithub: 70593
2016-02-24 11:08:18serhiy.storchakasetstatus: open -> closed
resolution: third party
messages: + msg260790

stage: resolved
2016-02-24 11:02:48rapolassetmessages: + msg260786
2016-02-24 10:40:44serhiy.storchakasetfiles: + issue26405.tcl
nosy: + terry.reedy
messages: + msg260785

2016-02-23 08:19:46rapolassetmessages: + msg260710
2016-02-22 17:44:01SilentGhostsetnosy: + paul.moore, gpolo, tim.golden, serhiy.storchaka, zach.ware, steve.dower
components: + Windows
2016-02-21 21:07:13rapolascreate