Tkinter- Building a message box

Discussion in 'Python' started by Tuvas, Nov 7, 2005.

  1. Tuvas

    Tuvas Guest

    I've been trying to build a fairly simple message box in tkinter, that
    when a button is pushed, will pop up a box, that has a line of text, an
    entry widget, and a button, that when the button is pushed, will return
    the value in the line of text. However, while I can read the value of
    the button, I want to wait till the button is pushed to return the
    value. Any ideas of how I could do this?
     
    Tuvas, Nov 7, 2005
    #1
    1. Advertising

  2. Tuvas

    Ron Adam Guest

    Tuvas wrote:
    > I've been trying to build a fairly simple message box in tkinter, that
    > when a button is pushed, will pop up a box, that has a line of text, an
    > entry widget, and a button, that when the button is pushed, will return
    > the value in the line of text. However, while I can read the value of
    > the button, I want to wait till the button is pushed to return the
    > value. Any ideas of how I could do this?


    The way I do it is to set self.result in the dialog to the return value
    just before closing and exiting.

    And then instead of openiug the dialog directly I use a function to pass
    and sometimes modify the values to the dialog and then return the
    dialog.result value after it's closed.

    Something like...

    def domydialog(*args, **kwds):
    #
    # Check and modify args or kwds here if needed.
    #
    mydialog(*args, **kwds)
    return mydialog.result

    Cheers,
    Ron
     
    Ron Adam, Nov 7, 2005
    #2
    1. Advertising

  3. Tuvas

    Tuvas Guest

    Do you have any info on dialogs? I've been trying to find some, without
    alot of success...
     
    Tuvas, Nov 7, 2005
    #3
  4. Tuvas

    Guest

    , Nov 7, 2005
    #4
  5. Tuvas

    Tuvas Guest

    Thanks alot, that helped TONS! Just had to modify it slightly, but,
    well, it works great now. Thanks!
     
    Tuvas, Nov 7, 2005
    #5
  6. Tuvas

    Ron Adam Guest

    Tuvas wrote:
    > Do you have any info on dialogs? I've been trying to find some, without
    > alot of success...
    >


    Be sure and look at the examples in python24/lib/lib-tk. The Dialog.py
    file there does pretty much what you want.

    In the dialog caller example I gave, it should have been ...

    def domydialog(*args, **kwds):
    #
    # check or change args or kwds
    #
    d = mydialog(*args, **kwds)
    return d.result

    I left out the returned object name 'd'. Which is needed to get the
    result from the dialog instance.

    Cheers,
    Ron
     
    Ron Adam, Nov 7, 2005
    #6
    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. Philippe C. Martin

    Tkinter zoom box = maximize/unmaximize box/button

    Philippe C. Martin, Jan 3, 2005, in forum: Python
    Replies:
    1
    Views:
    565
    Eric Brunel
    Jan 3, 2005
  2. bienwell
    Replies:
    5
    Views:
    5,207
    bienwell
    Aug 13, 2006
  3. Replies:
    0
    Views:
    365
  4. Guilherme Polo
    Replies:
    0
    Views:
    507
    Guilherme Polo
    Aug 28, 2008
  5. Replies:
    0
    Views:
    520
Loading...

Share This Page