How do I prevent master window from being accessed with child window present?

Discussion in 'Python' started by Marc, Aug 29, 2003.

  1. Marc

    Marc Guest

    Hi,

    I am doing a gui application where child windows pop up with options
    after the user selects particular buttons from the master window.
    However, the master window is still active underneath the child
    window. If they accidentally press the same button again they can get
    the same copy of two child windows, and that screws up a bunch of the
    database stuff that I am trying to collect.

    I have tried using the 'transient' method, and that prevents the
    master window from being highlighted. But the user can still push
    buttons on the master window if the child window is moved aside.

    How do I disable the master window until the child window is closed?

    Thanks,
    Marc
     
    Marc, Aug 29, 2003
    #1
    1. Advertising

  2. Marc

    Cliff Wells Guest

    Re: How do I prevent master window from being accessed with childwindow present?

    On Fri, 2003-08-29 at 11:12, Marc wrote:
    > Hi,
    >
    > I am doing a gui application where child windows pop up with options
    > after the user selects particular buttons from the master window.
    > However, the master window is still active underneath the child
    > window. If they accidentally press the same button again they can get
    > the same copy of two child windows, and that screws up a bunch of the
    > database stuff that I am trying to collect.
    >
    > I have tried using the 'transient' method, and that prevents the
    > master window from being highlighted. But the user can still push
    > buttons on the master window if the child window is moved aside.
    >
    > How do I disable the master window until the child window is closed?


    And which GUI toolkit are you using? Most have an option to open a
    window as "modal" (although this might be limited to dialogs for your
    particular toolkit) which means it retains the focus exclusively until
    it's dismissed.

    --
    Cliff Wells, Software Engineer
    Logiplex Corporation (www.logiplex.net)
    (503) 978-6726 (800) 735-0555
     
    Cliff Wells, Aug 29, 2003
    #2
    1. Advertising

  3. Marc

    Marc Guest

    Re: How do I prevent master window from being accessed with childwindow present?

    I guess knowing which kit would help. I am using Tkinter.


    "Cliff Wells" <> wrote in message
    news:...
    > On Fri, 2003-08-29 at 11:12, Marc wrote:
    > > Hi,
    > >
    > > I am doing a gui application where child windows pop up with options
    > > after the user selects particular buttons from the master window.
    > > However, the master window is still active underneath the child
    > > window. If they accidentally press the same button again they can get
    > > the same copy of two child windows, and that screws up a bunch of the
    > > database stuff that I am trying to collect.
    > >
    > > I have tried using the 'transient' method, and that prevents the
    > > master window from being highlighted. But the user can still push
    > > buttons on the master window if the child window is moved aside.
    > >
    > > How do I disable the master window until the child window is closed?

    >
    > And which GUI toolkit are you using? Most have an option to open a
    > window as "modal" (although this might be limited to dialogs for your
    > particular toolkit) which means it retains the focus exclusively until
    > it's dismissed.
    >
    > --
    > Cliff Wells, Software Engineer
    > Logiplex Corporation (www.logiplex.net)
    > (503) 978-6726 (800) 735-0555
    >
    >
     
    Marc, Aug 30, 2003
    #3
  4. Re: How do I prevent master window from being accessed with childwindow present?

    "Marc" <> schrieb im Newsbeitrag
    news:...
    > I guess knowing which kit would help. I am using Tkinter.
    >

    Of course you were usind Tkinter...

    (1) You can use the modal approach (have a look how Pmw are doing this.
    (2) Disable all your controls in the main widget when you show the child
    window.
    (3) "withdraw" the main window (this is not iconify!)

    Example:
    from Tkinter import *

    m=Tk()
    m.title("Parent")
    c=Toplevel(m)
    c.title("Child")
    Button(c,text="Hello",command=c.destroy).pack()

    c.bind("<Destroy>",lambda x:m.deiconify())
    # note we need lambda to get rid of the Destroy argument
    #we should "bind", because there are many ways a window can be killed

    m.withdraw()

    mainloop()
     
    Michael Peuser, Aug 30, 2003
    #4
  5. Marc

    Eric Brunel Guest

    Re: How do I prevent master window from being accessed with childwindow present?

    Marc wrote:
    > Hi,
    >
    > I am doing a gui application where child windows pop up with options
    > after the user selects particular buttons from the master window.
    > However, the master window is still active underneath the child
    > window. If they accidentally press the same button again they can get
    > the same copy of two child windows, and that screws up a bunch of the
    > database stuff that I am trying to collect.
    >
    > I have tried using the 'transient' method, and that prevents the
    > master window from being highlighted. But the user can still push
    > buttons on the master window if the child window is moved aside.
    >
    > How do I disable the master window until the child window is closed?


    childWindow.grab_set()

    HTH
    --
    - Eric Brunel <> -
    PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
     
    Eric Brunel, Sep 1, 2003
    #5
    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. Daniel
    Replies:
    7
    Views:
    509
  2. Ralf Wahner
    Replies:
    5
    Views:
    656
    Bob Foster
    Dec 24, 2003
  3. modemer
    Replies:
    20
    Views:
    1,396
    Howard
    Mar 22, 2005
  4. Jeff Rodriguez
    Replies:
    23
    Views:
    1,210
    David Schwartz
    Dec 9, 2003
  5. Daniel
    Replies:
    5
    Views:
    150
    kaeli
    Jan 26, 2004
Loading...

Share This Page