empty window when using askopenfile

Discussion in 'Python' started by Sorin Gherman, Apr 16, 2004.

  1. 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
    Sorin Gherman, Apr 16, 2004
    #1
    1. Advertising

  2. Sorin Gherman wrote:

    > 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?


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

    import Tkinter

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

    file = tkFileDialog.askopenfile(...)

    </F>

    Got Tkinter questions?
    http://mail.python.org/mailman/listinfo/tkinter-discuss
    has the answers.
    Fredrik Lundh, Apr 16, 2004
    #2
    1. Advertising

  3. Sorin Gherman

    Peter Otten Guest

    Sorin Gherman wrote:

    > 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?


    import Tkinter, tkFileDialog
    root = Tkinter.Tk()
    root.withdraw()
    tkFileDialog.askopenfile()

    Peter
    Peter Otten, Apr 16, 2004
    #3
  4. (Sorin Gherman) wrote in message news:<>...

    > 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?



    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.askopenfile()

    # 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 =)
    Lonnie Princehouse, Apr 16, 2004
    #4
    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. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,002
    Klaus Johannes Rusch
    Jul 16, 2003
  2. Lukas
    Replies:
    3
    Views:
    778
    spiff
    Nov 10, 2005
  3. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    557
    Dave Thompson
    Feb 14, 2004
  4. Brian Roberts

    empty lists vs empty generators

    Brian Roberts, May 3, 2005, in forum: Python
    Replies:
    12
    Views:
    628
    Jeremy Bowers
    May 4, 2005
  5. Soumen banerjee
    Replies:
    0
    Views:
    258
    Soumen banerjee
    Apr 13, 2009
Loading...

Share This Page