Python equivilant to msgbox()

Discussion in 'Python' started by LittlePython, Feb 13, 2006.

  1. LittlePython

    LittlePython Guest

    Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I would like to call this instead of print (to the screen) . I would like to write a simple script that is not an event drive gui but calls input boxes, message boxes, or maybe even a file open browser box as well?
    LittlePython, Feb 13, 2006
    1. Advertisements

  2. LittlePython

    Kent Johnson Guest

    Take a look at EasyGUI:

    Kent Johnson, Feb 13, 2006
    1. Advertisements

  3. LittlePython

    LittlePython Guest

    That is exactly what I was look for .. thx

    LittlePython, Feb 13, 2006
  4. It's also possible to something like that with wxPython. Try:
    import wx
    app = wx.PySimpleApp()
    dlg = wx.TextEntryDialog(None, 'Enter value', 'Title', '')
    if dlg.ShowModal() == wx.ID_OK:
    val = dlg.GetValue() # this line should be indented
    print "you have entered %s" % val
    =?iso-8859-1?B?QW5kcuk=?=, Feb 13, 2006
  5. LittlePython

    Peter Decker Guest

    That's the sort of butt-ugly code that got me convinced that Dabo is
    the way to go. To get a simple message box, you have to create it,
    show it, check a return value against an ugly constant (make sure you
    don't forget an use wx.OK instead!), and then remember to destroy it
    or your app will hang.

    The same code in Dabo is:

    val = dabo.ui.getString("Enter value", "Some Title")
    if val in None:
    print "You canceled"
    print "You entered %s" % val

    Look at both examples, and tell me which looks more Pythonic to you.
    Peter Decker, Feb 13, 2006
  6. if you're using a Python version without a "def" statement, it's time to upgrade.

    Fredrik Lundh, Feb 13, 2006
  7. While I agree that dabo's version is more Pythonic than wxPython, my
    understanding is that dabo is built on top of wxPython. There are
    other framework (wax, anygui) that also aim to make the coding "more
    pythonic", hiding "ugly" wxPython details. Personnally, I am hesitant
    to start using an extra layer on top of wxPython, with no guarantee
    that it will be always updated. Ideally, something like dabo+wxPython
    would become part of the standard Python distribution.

    The original post was asking if it was possible to have such message
    dialogs using Python, without having a full gui app. I'd say that the
    answer is yes... and that one has a lot of options, depending on how
    many packages one is ready to download.

    Andre Roberge, Feb 13, 2006
  8. LittlePython

    Peter Decker Guest

    Yes. You get all the power of wxPython without having to deal with the
    C++ style of coding.
    I think the chances of Dabo not getting updated are about the same as
    wxPython not getting updated. The authors have been highly active and
    involved for a few years now, unlike Wax or anygui. Bugs get fixed in
    hours usually, and enhancements to the tools are always being

    It would be way cool if the Powers that Be would adopt Dabo/wxPython
    as part of the language. The combination is so much more powerful and
    much better looking than Tkinter.
    Oh, I understand your response. But I know that when people who are
    familiar with Python first see wxPython code, their first reaction is
    usually not positive. I was just trying to show that you can create
    UIs easily and Pythonically.
    Peter Decker, Feb 13, 2006
  9. Surprised to hear that.

    As VisualBasic programmer I would expect you to have experience with
    ActiveX on Windows, where the best way to go with Python is to reuse all
    the ActiveX components and their known user interfaces (i.e. constants
    to use as parameter and constants for interpretation of return values)
    directly from within Python.

    A message box goes e.g. this way:
    after 45 seconds", 45, u"(MsgTitle)Testing WScript.Shell object:", 1)

    By the way: is there a ready for direct use timed self closing Ok/Cancel
    message box in any of the proposed GUI packages?

    Claudio Grondi, Feb 13, 2006
  10. LittlePython

    mtallen Guest

    mtallen, Feb 13, 2006
  11. LittlePython

    LittlePython Guest

    I am no VB programmer just dabble in vbscripting abit. The only one I am
    aware of is the popup as self closing. I never thought of using com.

    Do you know of any thing for a busy box in the same vain as easygui
    LittlePython, Feb 15, 2006
  12. Ok, so my remarks about COM were not for you.
    No, I don't, but it doesn't mean, that there is none considering myriads
    of various available COM components. My idea was to make you aware, that
    you can use your VB compiler for creating any ActiveX/COM components for
    usage with Python the way I have described, but as you write it seems
    not to be an option for you.

    So I have to admit, that EasyGUI is in your case apparently
    Claudio Grondi, Feb 15, 2006
  13. LittlePython

    LittlePython Guest

    I am glad you did remind me of WScript.Shell ... I have to keep in mind
    that most if not all of what I have been using in VBS is avail to me.
    LittlePython, Feb 15, 2006
  14. Maybe in this context it could be also worth for you to know, that on
    Windows you can use Python as a scripting language embedded in HTML
    <script> blocks same way as you can use JScript and VBScript. This makes
    the Internet browser a very good GUI alternative for anyone able to
    write HTML code utilizing the appropriate scripting interface to the
    interactive HTML page elements.

    Claudio Grondi, Feb 15, 2006
  15. LittlePython


    Apr 1, 2008
    Likes Received:

    I'm new here and saw this thread after searching for "python keyboard function" on Google. I'm a kind of hobbyist programmer (don't do much) ... written a 700 line program (to provide an automatic hosting function to a play by e-mail based game) but that was kinda unusual. Haven't done much for a while so I'm forgetting some of it but I decided to write a sorting program which sorts based on user choices where the choices are presented in pairs ... probably best not to ask why :)

    Can anyone explain to me in simple terms how to make EasyGui buttonbox work because it looks like the kind of thing that can present a user with a question and some customisable choice buttons? I hope to present two choices (strings) and three buttons (2 choices and cancel) so an example would be even better [cheesy grin].

    EDIT: Is OK ... I've sorted it :)


    Last edited: Apr 2, 2008
    Kyuuketsuki, Apr 1, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.