Re: Tkinter "withdraw" and "askstring" problem

Discussion in 'Python' started by Jeff Epler, Apr 12, 2005.

  1. Jeff Epler

    Jeff Epler Guest

    The answer has to do with a concept Tk calls "transient".
    wm transient window ?master?
    If master is specified, then the window manager is informed that
    window is a transient window (e.g. pull-down menu) working on
    behalf of master (where master is the path name for a top-level
    window). If master is specified as an empty string then window
    is marked as not being a transient window any more. Otherwise
    the command returns the path name of window’s current master, or
    an empty string if window isn’t currently a transient window. A
    transient window will mirror state changes in the master and
    inherit the state of the master when initially mapped. It is an
    error to attempt to make a window a transient of itself.

    In tkSimpleDialog, the dialog window is unconditionally made transient
    for the master. Windows is simply following the documentation: The
    askstring window "inherit the state of the master [i.e., withdrawn]
    when initially mapped".

    The fix is to modify tkSimpleDialog.Dialog.__init__ to only make the
    dialog transient for its master when the master is viewable. This
    mirrors what is done in dialog.tcl in Tk itself. You can either change
    tkSimpleDialog.py, or you can include a new definition of __init__ with
    these lines at the top, and the rest of the function the same:
    def __init__(self, parent, title = None):
    ''' the docstring ... '''
    Toplevel.__init__(self, parent)
    if parent.winfo_viewable():
    self.transient(parent)
    ...

    # Thanks for being so dynamic, Python!
    tkSimpleDialog.Dialog.__init__ = __init__; del __init__

    Jeff

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.1 (GNU/Linux)

    iD8DBQFCW9P9Jd01MZaTXX0RAoyiAJ9LThutTzZZbI9qrTgHocG3NjvORwCeOHPL
    Y1MOgSLsXt/jzkymHZf2gUQ=
    =ShII
    -----END PGP SIGNATURE-----
    Jeff Epler, Apr 12, 2005
    #1
    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. wes weston

    askstring => grab failes

    wes weston, Apr 26, 2004, in forum: Python
    Replies:
    1
    Views:
    440
    klappnase
    Apr 27, 2004
  2. Miki Tebeka
    Replies:
    0
    Views:
    520
    Miki Tebeka
    Apr 12, 2005
  3. iwl
    Replies:
    10
    Views:
    1,611
    jim-on-linux
    Mar 7, 2007
  4. Hidekazu IWAKI
    Replies:
    1
    Views:
    359
    Peter Otten
    Dec 14, 2009
  5. Hidekazu IWAKI
    Replies:
    0
    Views:
    506
    Hidekazu IWAKI
    Dec 15, 2009
Loading...

Share This Page