trying to use this on Linux (RH 8.0) and Windows 2000. When I first
upgraded from v2.2 to v2.3. I noticed that
tkFileDialog.as kopenfilename() returns a tuple on Cancel instead of
''. I found that the Windows version still returns a string (''). Now
I'm finding out that tkFileDialog.Di rectory().show( ) does this too.
d1=tkFileDialog .Directory().sh ow()
d2=tkFileDialog .Directory().sh ow()
type(d1),type(d 2) (<type 'tuple'>, <type '_tkinter.Tcl_O bj'>) d2 <path object at 0x08295a48> d2 <path object at 0x08295a48>
d1 is the result of a Cancel, d2 is the result of a Ok.
dir(d1) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
'__eq__', '__ge__', '__getattribute __', '__getitem__',
'__getnewargs__ ', '__getslice__', '__gt__', '__hash__', '__init__',
'__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__' , '__repr__', '__rmul__',
'__setattr__', '__str__']
dir(d2)
['__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute __',
'__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__' ,
'__repr__', '__setattr__', '__str__', '__unicode__', 'string',
'typename']
I thought this was a Tk8.3 vs Tk8.4 problem, so I put in a check:
d = tkFileDialog.Di rectory().show( )
if TkVersion < 8.4:
outdir=d
else:
outdir=d.string
if d : self.setoutpath (outdir)
Then when I tried this on a Windows machine, it turns out that
tkFileDialog.Di rectory().show( ) still returns a string when TkVersion
is 8.4
How can I check tkFileDialog to do the "right" thing? All I want is
the string that contains the path, but I want this to work on both
Linux and Windows.
Thanks.