tkFileDialog.askdirectory root directory ?

Discussion in 'Python' started by Ringwraith, Mar 1, 2004.

  1. Ringwraith

    Ringwraith Guest

    Hello!

    I have the following problem. I use the tkFileDialog.askdirectory dialog to
    allow users of my application to pick some subfolder from 'C:/my_app'
    directory. I use initialdir='C:/my_app' option to set 'C:/my_app' as initial
    directory. But I want my initial directory to be also a root directory, so
    the user cannot pick any directory outside 'C:/my_app' folder. I have no
    idea how to do it using standard tkFileDialog.askdirectory. Is that
    possible?

    Thank you in advance for any hints.

    Best wishes,

    Niki
    Ringwraith, Mar 1, 2004
    #1
    1. Advertising

  2. Ringwraith wrote:
    > Hello!
    >
    > I have the following problem. I use the tkFileDialog.askdirectory dialog to
    > allow users of my application to pick some subfolder from 'C:/my_app'
    > directory. I use initialdir='C:/my_app' option to set 'C:/my_app' as initial
    > directory. But I want my initial directory to be also a root directory, so
    > the user cannot pick any directory outside 'C:/my_app' folder. I have no
    > idea how to do it using standard tkFileDialog.askdirectory. Is that
    > possible?
    >
    > Thank you in advance for any hints.
    >
    > Best wishes,
    >
    > Niki
    >
    >


    Unles there is a speacial windows extra thingy I don't think you could
    stop the user selecting a directory not below C:/my_app however you can
    at least start the directory selector with that as it's initial
    directory like so:


    tkFileDialog.askdirectory(initialdir="C:/my_app")


    HTH
    Martin
    Martin Franklin, Mar 2, 2004
    #2
    1. Advertising

  3. In article <c206mk$lmi$>,
    "Ringwraith" <> wrote:

    >I have the following problem. I use the tkFileDialog.askdirectory dialog to
    >allow users of my application to pick some subfolder from 'C:/my_app'
    >directory. I use initialdir='C:/my_app' option to set 'C:/my_app' as initial
    >directory. But I want my initial directory to be also a root directory, so
    >the user cannot pick any directory outside 'C:/my_app' folder. I have no
    >idea how to do it using standard tkFileDialog.askdirectory. Is that
    >possible?


    Some possible solutions:
    - Write your own version that does this, e.g. via bindings that detect
    when the user tries to change directory and screens the requested
    change. Unfortunately, from a quick look at tkFileDialog, I did not see
    any easy way to adapt the existing code; unless I missed something you
    may have to pretty much code from scratch.
    - Allow the user to select anything, but then test it and reject it if
    it doesn't meet your requirements. This is trivial to code, but a pain
    for the user.
    - See if you can redesign your code to eliminate the requirement.

    -- Russell
    Russell E. Owen, Mar 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,201
  2. Rick Osborn
    Replies:
    10
    Views:
    3,939
    Jon A. Cruz
    Feb 8, 2004
  3. Mike Abel

    tkFileDialog.askdirectory

    Mike Abel, Dec 1, 2003, in forum: Python
    Replies:
    1
    Views:
    754
    Mike Abel
    Dec 1, 2003
  4. Read Roberts
    Replies:
    2
    Views:
    653
    Read Roberts
    Oct 8, 2004
  5. hector
    Replies:
    5
    Views:
    398
    CBFalconer
    Dec 5, 2006
Loading...

Share This Page