Hidden files, selecting directories, & taxes
Martin Franklin
martin.franklin at westgeo.com
Thu Feb 14 03:33:30 EST 2002
Christopher wrote:
> Hello everybody,
> I had a couple things to ask:
>
> 2) Is there a simple and easy way to allow the end-user to select a
> directory? For example, let's say all files of rpt type are saved to
> a certain directory (named by each user). And we want to perform an
> operation on each of the files, is there an easy way to get the
> directory (when I say easy, I mean something like
> tkFileDialog.askopenfilename or the like). Right now I skirt around
> the issue by asking the user to select one of the files they wish to
> process and then I us os calls to get the directory path then use
> listdir to get a list that I loop over. It's a bit of a cheesy method
> but I spent a significant amount of time making it feel 'natural.'
###Tk directory selection dialog:-
from tkCommonDialog import Dialog
class Chooser(Dialog):
command = "tk_chooseDirectory"
def _fixresult(self, widget, result):
if result:
self.options["initialdir"] = result
self.directory = result # compatibility
return result
def askdirectory(**options):
return apply(Chooser, (), options).show()
### for some reason this crashes on Win95 but not on any other win I
### tested...
>
> Chris
>
More information about the Python-list
mailing list