tkFileDialog.askdirectory

Mike Abel Ax10 at gmx.de
Mon Dec 1 14:09:30 EST 2003


Mike Abel <Ax10 at gmx.de> wrote:
> Hello

> i have a Linux Mandrake Distribution with Python 2.3 and Tcl/Tk 8.4.

> Python 2.2 and Tcl/Tk 8.3.3 returns an String if i made this:

> x = tkFileDialog.askdirectory(initialdir="was auch immer", title="xxx")
> print type(x)

> <type 'str'>

> With the combination Python 2.3 and Tcl/Tk 8.4 it returns
> <type '_tkinter.Tcl_Obj'>

> I have asked an other user (he used Windows 2000 Python 2.3.2
> Tcl/Tk 8.4) and it returns an string.

The reason for this is possibly this:

"Calling Tcl methods through _tkinter no longer returns only strings.
Instead, if Tcl returns other objects those objects are converted to
their Python equivalent, if one exists, or wrapped with a
_tkinter.Tcl_Obj object if no Python equivalent exists. This behavior
can be controlled through the wantobjects() method of tkapp objects.
When using _tkinter through the Tkinter module (as most Tkinter
applications will), this feature is always activated. It should not
cause compatibility problems, since Tkinter would always convert string
results to Python types where possible.

If any incompatibilities are found, the old behavior can be restored by
setting the wantobjects variable in the Tkinter module to false before
creating the first tkapp object.


import Tkinter
Tkinter.wantobjects = 0

Any breakage caused by this change should be reported as a bug."


Thanks to Klaus




More information about the Python-list mailing list