tkFileDialog without a parent window

Discussion in 'Python' started by Stephen Boulet, Jul 3, 2003.

  1. I'm using the following code to get a file name:

    import tkFileDialog
    tkFileDialog.askopenfilename(filetypes=[("HDF Files", ".hdf")])

    How can I do this without an empty tk window popping up and hanging around
    after the dialog is closed? Thanks.

    -- Stephen
     
    Stephen Boulet, Jul 3, 2003
    #1
    1. Advertising

  2. Stephen Boulet

    Mike Abel Guest

    Stephen Boulet <> wrote:

    > How can I do this without an empty tk window popping up and hanging around
    > after the dialog is closed? Thanks.



    Well i think this is probably a problem in your script not a
    problem from tkFileDialog.

    Mike
     
    Mike Abel, Jul 5, 2003
    #2
    1. Advertising

  3. Stephen Boulet

    klappnase Guest

    Stephen Boulet <> wrote in message news:<be21e4$trp$>...
    > I'm using the following code to get a file name:
    >
    > import tkFileDialog
    > tkFileDialog.askopenfilename(filetypes=[("HDF Files", ".hdf")])
    >
    > How can I do this without an empty tk window popping up and hanging around
    > after the dialog is closed? Thanks.
    >
    > -- Stephen


    Hi,

    you may use the withdraw() method on the root window:

    root = Tk()
    root.withdraw()
    somefile = tkFileDialog.askopenfilename(filetypes=[("HDF Files", ".hdf")])
    ....

    Cheers

    michael
     
    klappnase, Jul 20, 2003
    #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. Tim Williams
    Replies:
    0
    Views:
    658
    Tim Williams
    Aug 4, 2003
  2. Frank Chen
    Replies:
    3
    Views:
    523
    Cameron Laird
    Oct 8, 2003
  3. Mike Abel

    tkFileDialog.askdirectory

    Mike Abel, Dec 1, 2003, in forum: Python
    Replies:
    1
    Views:
    792
    Mike Abel
    Dec 1, 2003
  4. Tim Williams
    Replies:
    3
    Views:
    634
    Tim Williams
    Dec 11, 2003
  5. PWalker
    Replies:
    1
    Views:
    139
    David Lionetti
    Feb 24, 2005
Loading...

Share This Page