Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24955 > unrolled thread

tkFileDialogs

Started bybrandon harris <brandon.harris@reelfx.com>
First post2012-07-06 05:22 +0000
Last post2012-07-06 09:17 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  tkFileDialogs brandon harris <brandon.harris@reelfx.com> - 2012-07-06 05:22 +0000
    Re: tkFileDialogs Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-06 09:17 -0700

#24955 — tkFileDialogs

Frombrandon harris <brandon.harris@reelfx.com>
Date2012-07-06 05:22 +0000
SubjecttkFileDialogs
Message-ID<mailman.1849.1341552375.4697.python-list@python.org>
I'm wanting to allow users to select hidden directories in windows and it seems that using the tkFileDialog.askdirectory() won't allow for that.  It's using the tkFileDialog.Directory class which calls an internal command 'tk_chooseDirectory' .  However the file selector dialogs (askopenfilename, asksaveasfilename, etc) has the common windows dialog which supports showing hidden folders.  It's using the tkFileDialog.Open class which is calling an internal command of 'tk_getOpenFile'.

Can anyone shed light on why these two dialogs are so very different and possibly give me a solution to this hidden directory issue.  I have found that you can't really use the Open class because it's going to require a file be selected, not a directory and the Directory class won't navigate to or have an initialdir that is hidden (on windows the %APPDAT% folder is hidden by default)

Windows Example Code.

import tkFileDialog
# Won't start in or allow navigation to APPDATA
test = tkFileDialog.askdirectory(initialdir='%APPDATA%')
# Will start in and navigate to APPDATA
test = tkFileDialog.askopenfile(initialdir='%APPDATA%')

Thanks in advance for any help given!


Brandon L. Harris

[toc] | [next] | [standalone]


#24974

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2012-07-06 09:17 -0700
Message-ID<9177eeb0-da29-4c83-b370-e810a1cb085b@w6g2000yqg.googlegroups.com>
In reply to#24955
On Jul 6, 12:22 am, brandon harris <brandon.har...@reelfx.com> wrote:
> [...]
> import tkFileDialog
> # Won't start in or allow navigation to APPDATA
> test = tkFileDialog.askdirectory(initialdir='%APPDATA%')
> # Will start in and navigate to APPDATA
> test = tkFileDialog.askopenfile(initialdir='%APPDATA%')

Don't you just love inconsistencies! I get weird results using your
"string". Why not use expanduser?

py> path = os.path.expanduser('~\\AppData')

Of course that will not solve your main problem though. Probably since
showing hidden files is a function of the OS setting, which explorer
follows blindly. I tried your code AFTER changing "show
hidden_files_and_folders=True" and both dialogs open into the correct
directory, as expected. You could modify the setting, then show the
dialog, then revert the setting back.

Ah. The joys of Win32 scripting... *chokes*

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web