469,282 Members | 1,749 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Python equivilant to msgbox()

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?
Feb 13 '06 #1
13 15012
LittlePython wrote:
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
Feb 13 '06 #2
That is exactly what I was look for .. thx
"Kent Johnson" <ke**@kentsjohnson.com> wrote in message
news:43**********@newspeer2.tds.net...
LittlePython wrote:
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

Feb 13 '06 #3
Kent Johnson wrote:
LittlePython wrote:
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

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

Feb 13 '06 #4
On 12 Feb 2006 17:27:56 -0800, André <an***********@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.
Feb 13 '06 #5
Peter Decker 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.


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

</F>

Feb 13 '06 #6
On 2/13/06, Peter Decker <py******@gmail.com> wrote:
On 12 Feb 2006 17:27:56 -0800, André <an***********@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.


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é
Feb 13 '06 #7
On 2/13/06, Andre Roberge <an***********@gmail.com> wrote:
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.

--

# p.d.
Feb 13 '06 #8
LittlePython wrote:
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:
import win32com.client
axWshShell = win32com.client.Dispatch("WScript.Shell")
axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself

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

"Kent Johnson" <ke**@kentsjohnson.com> wrote in message
news:43**********@newspeer2.tds.net...
LittlePython wrote:
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


Feb 13 '06 #9
Or just do the message box.
import CLR.System.Windows.Forms as Forms
Forms.MessageBox.Show("message goes here", "Window title goes here")


http://www.zope.org/Members/Brian/PythonNet/

In theory this will also work on a linux system with Mono installed

Feb 13 '06 #10
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
"Claudio Grondi" <cl************@freenet.de> wrote in message
news:ds**********@newsreader3.netcologne.de...
LittlePython wrote:
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:
>>> import win32com.client
>>> axWshShell = win32com.client.Dispatch("WScript.Shell")
>>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself

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


"Kent Johnson" <ke**@kentsjohnson.com> wrote in message
news:43**********@newspeer2.tds.net...
LittlePython wrote:

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


Feb 15 '06 #11
LittlePython wrote:
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
exactly what you was looking for ...


:-)

Claudio

"Claudio Grondi" <cl************@freenet.de> wrote in message
news:ds**********@newsreader3.netcologne.de...
LittlePython wrote:
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:
>>> import win32com.client
>>> axWshShell = win32com.client.Dispatch("WScript.Shell")
>>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself

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

"Kent Johnson" <ke**@kentsjohnson.com> wrote in message
news:43**********@newspeer2.tds.net...
LittlePython wrote:
>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


Feb 15 '06 #12
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

"Claudio Grondi" <cl************@freenet.de> wrote in message
news:ds*********@newsreader3.netcologne.de...
LittlePython wrote:
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
exactly what you was looking for ...


:-)

Claudio


"Claudio Grondi" <cl************@freenet.de> wrote in message
news:ds**********@newsreader3.netcologne.de...
LittlePython wrote:

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:

>>> import win32com.client
>>> axWshShell = win32com.client.Dispatch("WScript.Shell")
>>> axWshShell.Popup(u"(MsgText)This axWshShell.Popup closes itself
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
"Kent Johnson" <ke**@kentsjohnson.com> wrote in message
news:43**********@newspeer2.tds.net...
>LittlePython wrote:
>
>
>>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


Feb 15 '06 #13
LittlePython wrote:
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
Feb 15 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by marco | last post: by
reply views Thread by justin worrall | last post: by
2 posts views Thread by Kevin T. Ryan | last post: by
9 posts views Thread by StepH | last post: by
63 posts views Thread by Nick Palmer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.