tkFileDialog.askdirectory

M

Mike Abel

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.

Is the Python version the reason or what goes wrong,
or is it a new feature?

Mike
 
M

Mike Abel

Mike Abel said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,476
Latest member
blackwatermelon

Latest Threads

Top