Python equivilant to msgbox()

Peter Decker pydecker at gmail.com
Mon Feb 13 08:02:09 EST 2006


On 12 Feb 2006 17:27:56 -0800, André <andre.roberge at gmail.com> wrote:

> 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
> dlg.Destroy()
> print "you have entered %s" % val

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"
else:
   print "You entered %s" % val

Look at both examples, and tell me which looks more Pythonic to you.

--

# p.d.



More information about the Python-list mailing list