Open 4LT opened 1 year ago
On macOS this returns ""
.
The underlying Tcl/Tk command tk_chooseDirectory
(as well as tk_getOpenFile
and tk_getSaveFile
) has implementations for each platform. From Tcl/Tk’s perspective, clicking “cancel” causes an empty string value to be returned regardless of platform. However incidental differences between these implementations are causing the returned empty string value to either be unshared and untyped on Win32 and Aqua, or highly shared and often having type (such as "list", since the empty string is the empty Tcl list) on X11. And in general Tkinter does not automatically convert a Tcl value to a Python string if it has a type (other than "string").
A similar issue was already addressed for tkinter.colorchooser.Chooser
: #48017
It would perhaps be more Pythonic to return None
as a special value. Some other dialogs already return None
if cancelled (for example askyesnocancel()
and askstring()
).
Bug report
Native Linux binary and Windows executable (under Wine) have different behaviors for tkinter's
filedialog.askdirectory
. Clicking "Cancel" results in a return value of()
(empty tuple) under Linux, and""
for the Windows executable.Your environment
3.11
Arch Linux 6.2.9 natively AND under Wine 8.5
Linked PRs