empty window when using askopenfile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sorin Gherman

    empty window when using askopenfile

    Is there any way to minimize/hide the annoying default, empty Tk
    window that shows behind the native file opening dialog , when using
    askopenfile, etc, in tkCommonDialog?

    I am using Python 2.3.2 on winXP.

    Thanks in advance,
    Sorin Gherman
  • Peter Otten

    #2
    Re: empty window when using askopenfile

    Sorin Gherman wrote:
    [color=blue]
    > Is there any way to minimize/hide the annoying default, empty Tk
    > window that shows behind the native file opening dialog , when using
    > askopenfile, etc, in tkCommonDialog?[/color]

    import Tkinter, tkFileDialog
    root = Tkinter.Tk()
    root.withdraw()
    tkFileDialog.as kopenfile()

    Peter

    Comment

    • Fredrik Lundh

      #3
      Re: empty window when using askopenfile

      Sorin Gherman wrote:
      [color=blue]
      > Is there any way to minimize/hide the annoying default, empty Tk
      > window that shows behind the native file opening dialog , when using
      > askopenfile, etc, in tkCommonDialog?[/color]

      explicitly create the root window, and withdraw it from the
      screen before you call askopenfile:

      import Tkinter

      root = Tkinter.Tk()
      root.withdraw()

      file = tkFileDialog.as kopenfile(...)

      </F>

      Got Tkinter questions?

      has the answers.




      Comment

      • Lonnie Princehouse

        #4
        Re: empty window when using askopenfile

        s_gherman@yahoo .com (Sorin Gherman) wrote in message news:<ac259413. 0404161054.3bca eaa8@posting.go ogle.com>...
        [color=blue]
        > Is there any way to minimize/hide the annoying default, empty Tk
        > window that shows behind the native file opening dialog , when using
        > askopenfile, etc, in tkCommonDialog?[/color]


        Ah, the pesky Tk root window. You can minimize it, but I don't think
        you can make it disappear completely (without nuking the rest of Tk).

        Try this-

        import Tkinter, tkFileDialog

        tkroot = Tkinter.Tk()
        tkroot.iconify( )

        tkFileDialog.as kopenfile()

        # If you're not doing anything with Tk besides prompting for the file,
        # you'll want to get ride of the root window after askopenfile-
        tkroot.destroy( )


        Alternately, you could just put a pretty picture in the root window
        and call it a feature =)

        Comment

        Working...