tkFileDialog without a parent window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen Boulet

    tkFileDialog without a parent window

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

    import tkFileDialog
    tkFileDialog.as kopenfilename(f iletypes=[("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

  • Mike Abel

    #2
    Re: tkFileDialog without a parent window

    Stephen Boulet <stephen.boulet @motorola.com> wrote:
    [color=blue]
    > How can I do this without an empty tk window popping up and hanging around
    > after the dialog is closed? Thanks.[/color]


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

    Mike

    Comment

    • klappnase

      #3
      Re: tkFileDialog without a parent window

      Stephen Boulet <stephen.boulet @motorola.com> wrote in message news:<be21e4$tr p$1@localhost.l ocaldomain>...[color=blue]
      > I'm using the following code to get a file name:
      >
      > import tkFileDialog
      > tkFileDialog.as kopenfilename(f iletypes=[("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[/color]

      Hi,

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

      root = Tk()
      root.withdraw()
      somefile = tkFileDialog.as kopenfilename(f iletypes=[("HDF Files", ".hdf")])
      ....

      Cheers

      michael

      Comment

      Working...