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. Advertisements

  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. Advertisements

  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. Advertisements

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. Raj
    Replies:
    3
    Views:
    13,323
    gautamkhosla29
    Jun 11, 2009
  2. KenG

    window.open clears parent window

    KenG, Feb 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    7,643
    Mike Hennessy
    Feb 17, 2004
  3. Earl Teigrob
    Replies:
    4
    Views:
    1,420
    Vidar Petursson
    Jun 5, 2004
  4. Earl Teigrob
    Replies:
    1
    Views:
    6,176
    Earl Teigrob
    Jun 16, 2004
  5. thomas
    Replies:
    0
    Views:
    423
    thomas
    Oct 23, 2003
  6. PerryC
    Replies:
    28
    Views:
    784
    Ivan Marsh
    Jul 13, 2004
  7. PWalker
    Replies:
    1
    Views:
    281
    David Lionetti
    Feb 24, 2005
  8. Tony
    Replies:
    10
    Views:
    481
    Randy Webb
    Feb 22, 2007
Loading...