Simple Dialogs

N

neil.fraser

I'm looking for a lightweight dialog boxes from Python.
JavaScript uses: alert(), confirm() and prompt()
VB uses: MsgBox() and InputBox()
EasyGui seemed perfect, but a "Hello World" application takes nearly a
minute to execute after the program has been compiled by py2exe.

There appear to be dozens of windowing toolkits avilable for Python,
could someone point me in the direction of something lightweight?

Thanks.
 
J

James Stroud

py> from tkMessageBox import askquestion, showerror
py> from tkSimpleDialog import askfloa
py> a = askfloat('Census Data', 'Enter Salary')
py> print a
12500.51
py> a = askquestion('Opinion', 'Do you think windoze sucks?')
py> print a
yes
py> a = showerror('Problem','Program Crashed before Starting')
py> print a
ok

I'm looking for a lightweight dialog boxes from Python.
JavaScript uses: alert(), confirm() and prompt()
VB uses: MsgBox() and InputBox()
EasyGui seemed perfect, but a "Hello World" application takes nearly a
minute to execute after the program has been compiled by py2exe.

There appear to be dozens of windowing toolkits avilable for Python,
could someone point me in the direction of something lightweight?

Thanks.

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
N

neil.fraser

James said:
from tkMessageBox import showerror
showerror('Problem','Program Crashed before Starting')

Thanks. That works great when interpreted (though a blank window seems
to open as well). Unfortunately it still takes 40 seconds to execute
after it has been 'compiled' with py2exe (I've only got a P3). This
probably has something to do with the fact that the resulting files for
this two-liner weigh in at just under 8MB.

Sounds like I'll need to write a one-line msgbox.exe in Visual Whatever
or Euphoria and execute that from Python.
 
N

neil.fraser

James said:
from tkMessageBox import showerror
showerror('Problem','Program Crashed before Starting')

Here's a faster method, though not cross-platform:

import ctypes
ctypes.windll.user32.MessageBoxA(0, "Hello World", "Title", 0x00)
 
G

Grant Edwards

Here's a faster method, though not cross-platform:

import ctypes
ctypes.windll.user32.MessageBoxA(0, "Hello World", "Title", 0x00)

Another easy way to do a dialog box:

import os
os.system('Xdialog --msgbox "Hello World" 0 0')
 
T

Thorsten Kampe

* (e-mail address removed) (2005-09-23 23:39 +0100)
Thanks. That works great when interpreted (though a blank window seems
to open as well). Unfortunately it still takes 40 seconds to execute
after it has been 'compiled' with py2exe (I've only got a P3). This
probably has something to do with the fact that the resulting files for
this two-liner weigh in at just under 8MB.

Try with Pyinstaller. There are issues with py2exe and EasyGui. I have
a script that uses either EasyGui or EasyDialog (on Windows) and the
Tkinter part crashes constantly (newest py2exe) while EasyDialogs
works just fine.

Compiled with Pyinstaller they both work fine (and the exe is at 1.7
MB)
 
S

Steve Holden

Grant said:
Another easy way to do a dialog box:

import os
os.system('Xdialog --msgbox "Hello World" 0 0')

Doesn't seem to work on my Winodws system at all ;-)

regards
Steve
 
G

Grant Edwards

Doesn't seem to work on my Winodws system at all ;-)

Odd. You don't have a full compliment of the usual GTK apps
installed?

I probably should have mentioned that Xdialog is a GTK+ app and
it needs to be installed and working on your platform.

In thoery, you could get it to work under Windows, but the last
time I checked, the Windows port of GTK+ was still a bit "beta".
 
W

William Park

I'm looking for a lightweight dialog boxes from Python.
JavaScript uses: alert(), confirm() and prompt()
VB uses: MsgBox() and InputBox()
EasyGui seemed perfect, but a "Hello World" application takes nearly a
minute to execute after the program has been compiled by py2exe.

There appear to be dozens of windowing toolkits avilable for Python,
could someone point me in the direction of something lightweight?

If you can run it outside Python, then
http://home.eol.ca/~parkw/index.html#gtk
will get you started.

If you must run it inside Python, then you should look into Python
wrapper for GTK+, and write the code yourself.

--
William Park <[email protected]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,007
Latest member
Elvis60357

Latest Threads

Top