hi ,

i just start to learn python.

i am doing window browser using python for that i am using tkFileDialog module. But when i select any folder, at the same time i want to display the files and folders which contain in that folder. Exactly like window browser. So i want to know is there any command like listbox.curselection() ?

please help me.

thanks.

Recommended Answers

All 2 Replies

Well, the tkFileDialog has as you know a number of dialogs such as tkFileDialog.askopenfiles(). These are modal dialogs, meaning that once they are instantiated, they grab control and don't give it back until they return.

So generally, No: you can't peek inside the details of the selection process.

However, buried inside the tkFileDialog code is a list of options to help filter the choices. (It's really annoying, BTW, that these options aren't listed when you help(tkFileDialog) or any of its children)

#
# options (all have default values):
#
# - defaultextension: added to filename if not explicitly given
#
# - filetypes: sequence of (label, pattern) tuples.  the same pattern
#   may occur with several patterns.  use "*" as pattern to indicate
#   all files.
#
# - initialdir: initial directory.  preserved by dialog instance.
#
# - initialfile: initial file (ignored by the open dialog).  preserved
#   by dialog instance.
#
# - parent: which window to place the dialog on top of
#
# - title: dialog title
#
# - multiple: if true user may select more than one file
#
# options for the directory chooser:
#
# - initialdir, parent, title: see above
#
# - mustexist: if true, user must pick an existing directory
#
#

Some of these might help you do what you want.

Hope it helps,
Jeff

Well, the tkFileDialog has as you know a number of dialogs such as tkFileDialog.askopenfiles(). These are modal dialogs, meaning that once they are instantiated, they grab control and don't give it back until they return.

So generally, No: you can't peek inside the details of the selection process.

However, buried inside the tkFileDialog code is a list of options to help filter the choices. (It's really annoying, BTW, that these options aren't listed when you help(tkFileDialog) or any of its children)

#
# options (all have default values):
#
# - defaultextension: added to filename if not explicitly given
#
# - filetypes: sequence of (label, pattern) tuples.  the same pattern
#   may occur with several patterns.  use "*" as pattern to indicate
#   all files.
#
# - initialdir: initial directory.  preserved by dialog instance.
#
# - initialfile: initial file (ignored by the open dialog).  preserved
#   by dialog instance.
#
# - parent: which window to place the dialog on top of
#
# - title: dialog title
#
# - multiple: if true user may select more than one file
#
# options for the directory chooser:
#
# - initialdir, parent, title: see above
#
# - mustexist: if true, user must pick an existing directory
#
#

Some of these might help you do what you want.

Hope it helps,
Jeff

thanks jrcagle,

i know those dialogs.
but i want to callback function when we select any folder at the same time print the list of folders and files which contain in selected file in another window or run any another programm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.