Python equivilant to msgbox()

L

LittlePython

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?
 
K

Kent Johnson

LittlePython said:
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?

Take a look at EasyGUI:
http://www.ferg.org/easygui/

Kent
 
?

=?iso-8859-1?B?QW5kcuk=?=

Kent said:
Take a look at EasyGUI:
http://www.ferg.org/easygui/

Kent
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
 
P

Peter Decker

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.
 
F

Fredrik Lundh

Peter said:
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.

if you're using a Python version without a "def" statement, it's time to upgrade.

</F>
 
A

Andre Roberge

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.

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.

André
 
P

Peter Decker

While I agree that dabo's version is more Pythonic than wxPython, my
understanding is that dabo is built on top of wxPython.

Yes. You get all the power of wxPython without having to deal with the
C++ style of coding.
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.

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
released.

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.
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.

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.
 
C

Claudio Grondi

LittlePython said:
That is exactly what I was look for .. thx
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
 
L

LittlePython

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
 
C

Claudio Grondi

LittlePython said:
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.
Ok, so my remarks about COM were not for you.
Do you know of any thing for a busy box in the same vain as easygui
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
 
L

LittlePython

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.
Thx
 
C

Claudio Grondi

LittlePython said:
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.
Thx
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
 
Joined
Apr 1, 2008
Messages
1
Reaction score
0
Hi,

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 :)

Thanks

Kyu
 
Last edited:

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top