tkFileDialog.askopenfilename filetypes problem

J

Justin Straube

Hopefully someone can catch what im missing here. Ive googled this and I think
Ive got the filetypes arg written properly, but I get a traceback when calling
this function.

Heres the code followed by its traceback.

def do_ask_fn_1():
z = askopenfilename(title=TITLE, initialdir=Dst_Dir,
filetypes=(('AIFF Files','*.aiff'),
("AU Files", "*.au"),
("RAW Files", "*.raw"),
("SD Files", "*.sd"),
("SND Files", "*.snd"),
("WAV files", "*.wav")
)
)
print z


Exception in Tkinter callback
Traceback (most recent call last):
File "E:\PYTHON~1\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "P:\work\Python\PYZoid\PYZoid.pyw", line 213, in do_ask_fn_1
filetypes=[('AIFF Files','*.aiff'),
TypeError: askopenfilename() takes exactly 0 non-keyword arguments (1 given)

Can anyone point to what Ive done wrong? Thanks for any input.

Justin
 
E

Eugene Druker

For me this:

z = tkFileDialog.askopenfilename(title='Title',
filetypes=[
('AIFF Files','*.aiff'),
("TXT Files", "*.txt"),
],
initialdir=InputDir)
print z

works fine.
Eugene
 

jgm

Joined
Sep 24, 2006
Messages
5
Reaction score
0
I see that in filetypes are missing the enclosing [], that denotes a list (of tuples). I changed the () by [] in your quoted message down:
Justin Straube said:
Hopefully someone can catch what im missing here. Ive googled this and I think
Ive got the filetypes arg written properly, but I get a traceback when calling
this function.

Heres the code followed by its traceback.

def do_ask_fn_1():
z = askopenfilename(title=TITLE, initialdir=Dst_Dir,
filetypes=[('AIFF Files','*.aiff'),
("AU Files", "*.au"),
("RAW Files", "*.raw"),
("SD Files", "*.sd"),
("SND Files", "*.snd"),
("WAV files", "*.wav")
]
)
print z


Exception in Tkinter callback
Traceback (most recent call last):
File "E:\PYTHON~1\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "P:\work\Python\PYZoid\PYZoid.pyw", line 213, in do_ask_fn_1
filetypes=[('AIFF Files','*.aiff'),
TypeError: askopenfilename() takes exactly 0 non-keyword arguments (1 given)

Can anyone point to what Ive done wrong? Thanks for any input.

Justin
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top