How to get the user name, and to show a select directory dialog?

Steve Holden sholden at holdenweb.com
Thu May 22 17:51:41 EDT 2003


"Arnal" <arnaud at tribu.ch> wrote ...
> Hi!
>
> I would like to obtain the name of the current logged user on a Windows
> machine, so I can get the "My documents" and "Desktop" folders.
>
This works for me on Win2K, but YMMV:

    import getpass; print getpass.getuser()

> I want to allow the user to specify the initial directory of the save
> command, and the open command. The "My documents" would be somehow basic
to
> acceess, but I must have the username in the path (or can I access this
> folder directly with a function?). Or how to access the user name, else?
>
You are assuming, I presume, that users haven't modified the location of
their "My Documents" folder, or perhaps you didn't know they could do that?

> I would like, as well, to show a "select directory dialog". I can already
> put a select file and put file; I think that selecting a directory must be
> in the same module, isn't it?
>
Not sure what you mean here. The technique you require will almost certainly
depend on the specific windowing technolog you are using -- wxPython,
Tkinter, PyQT, etc.

regards
--
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/







More information about the Python-list mailing list