By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,245 Members | 2,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,245 IT Pros & Developers. It's quick & easy.

Write a GUI for a python script?

P: n/a
I am a newbie with Python. It's a great language, but I would like to be
able to present a simple gui menu for some of my scripts; something better
than using 'raw_input' prompts.

Any recommendations for a program that will allow me to create the gui
screens? Something useable in Linux.

thanks.

Mar 2 '06 #1
Share this Question
Share on Google+
22 Replies


P: n/a
Tkinter is the GUI toolkit that comes with Python and is available on
all platform without any
installation effort. It is quite OK for simple things and I would
recommend it for any beginner.
Google for "An Introduction to Tkinter" by F. Lund.

Michele Simionato

Mar 2 '06 #2

P: n/a
wxPython is another good option, especially since there is
boa-constructor, which is a great GUI builder, almost makes it too easy
to make a nice looking app in no time at all.

http://www.wxpython.org/download.php

http://boa-constructor.sourceforge.net/

if you decide to give wxPython a go, make sure to download the demo, it
has tons of usefull code samples.

Mar 2 '06 #3

P: n/a
ianaré wrote:
wxPython is another good option, especially since there is
boa-constructor, which is a great GUI builder, almost makes it too easy
to make a nice looking app in no time at all.

http://www.wxpython.org/download.php

http://boa-constructor.sourceforge.net/

if you decide to give wxPython a go, make sure to download the demo, it
has tons of usefull code samples.


What is the minimal memory footprint of a Hello World wxPython app
meanwhile (when you cx_freeze/py2exe it) ?

Can you debug & call functions interactively from e.g. Pythonwin while a
wxPython app is running.

( When I made a test with wxPython some years ago, it had no option to
step/share its Messageloop. Interaction was "crust"y and I didn't manage
to get smooth debugging (on Windows). )

Robert
Mar 2 '06 #4

P: n/a
Glurt Wuntal wrote:
I am a newbie with Python. It's a great language, but I would like to be
able to present a simple gui menu for some of my scripts; something better
than using 'raw_input' prompts.

Any recommendations for a program that will allow me to create the gui
screens? Something useable in Linux.

thanks.


There are Python bindings to most GUI toolkits (GTK+, Qt, fltk, wxWindows,
and Tk come to mind). You could use any of them. They're all usable in
GNU/Linux.

-- Tk is a mature, small, and simple toolkit. The Python binding
to Tk is called Tkinter.

-- GTK+ is what most Gnome apps use. The Python binding is PyGTK.
http://www.pygtk.org/

-- Qt is what most KDE apps use. The Python binding is called PyQt.

-- wxWindows is a lot like MS Windows MFC if I recall correctly.
The Python binding to wxWindows is called wxPython.
http://www.wxpython.org/

-- For a terminal-based text-mode character-cell display program, you
could use ncurses. http://www.amk.ca/python/howto/curses/
http://gnosis.cx/publish/programming..._python_6.html
---John
--
(remove zeez if demunging email address)
Mar 2 '06 #5

P: n/a
John M. Gabriele wrote:

There are Python bindings to most GUI toolkits (GTK+, Qt, fltk, wxWindows,
and Tk come to mind).


Whoops. Forgot fltk with the pyFLTK Python binding. fltk
is a fast, light, toolkit that's written in C++ but (again,
IIRC) feels more like C-with-classes (which isn't a bad thing).

---John
--
(remove zeez if demunging email address)
Mar 2 '06 #6

P: n/a
On Thu, 02 Mar 2006 19:52:34 +0100
robert <no*****@no-spam-no-spam.com> wrote:
Can you debug & call functions interactively from e.g. Pythonwin while a
wxPython app is running.


It's a snap to incorporate a nice GUI Python shell with object browser
into any wxPython app - wxPython provides its PyCrust shell as a
package, which provides your choice of a widget you can embed or a
top-level window you can create. In one app I worked on I created a
menu item that launched such a shell window, so I could poke around
inside the app.

As far as actual debugging/stepping... I'm not sure. I haven' thad much
luck with Python debugging using anything but Wing IDE.

- Michael

--
mouse, n: a device for pointing at the xterm in which you want to type.
-- Fortune
Mar 2 '06 #7

P: n/a
On 3/2/06, robert <no*****@no-spam-no-spam.com> wrote:
ianaré wrote:
wxPython is another good option, especially since there is
boa-constructor, which is a great GUI builder, almost makes it too easy
to make a nice looking app in no time at all.

http://www.wxpython.org/download.php

http://boa-constructor.sourceforge.net/

if you decide to give wxPython a go, make sure to download the demo, it
has tons of usefull code samples.
What is the minimal memory footprint of a Hello World wxPython app
meanwhile (when you cx_freeze/py2exe it) ?


I'm assuming you mean disk space and not memory usage. A stock
wxPython (from a standard release) wil vary from platform to platform
but is generally about 2.5 megs. This can be brought down rather a lot
if you're willing to spend a fair amount of time learning the
wxWidgets and wxPython build systems and making custom builds but it's
not generally worth the time to me (and I know the build system and
could make customized builds if I wanted to)

I have a non-trivial wxPython application and, using py2exe in "single
executable" mode (thus all the dlls and the zipfile with the .pyc
files are included in the exe) it's just over 5 megs in size.
Can you debug & call functions interactively from e.g. Pythonwin while a
wxPython app is running.

I've never tried it with PythonWin and I don't know how PythonWin
hooks into Python to manage debugging). Both pdb and the debugger in
PyDev work fine for me, however. As another responder said it's
trivial (literally < 5 lines) to add an interactive Python shell to a
wxPython application, which is invaluable for debugging and testing.
( When I made a test with wxPython some years ago, it had no option to
step/share its Messageloop. Interaction was "crust"y and I didn't manage
to get smooth debugging (on Windows). )

I don't believe that wxPython exposes the low level C++ APIs that're
available to hook the wx message loop (it's an efficency issue, from
what I understand), but there are a number of other methods for
integration. The need to hook the message loop is far far less common
than the number of people who ask for it, so you'll forgive me if I'm
skeptical unless someone actually says why they want to.
Robert
--
http://mail.python.org/mailman/listinfo/python-list

Mar 2 '06 #8

P: n/a
> What is the minimal memory footprint of a Hello World wxPython app
meanwhile (when you cx_freeze/py2exe it)


it's kinda weird actually... I'm not 100% sure, but i think it relates
more to py2exe options, not neccessarily to wxPython. in any case the
least memory usage i've seen for an app that has at least some degree
of functionality is around 12k running on win2000. But a much more
complicated and larger app uses about 16k, while another small app uses
like 20k...
???

Mar 2 '06 #9

P: n/a
John M. Gabriele wrote:
-- GTK+ is what most Gnome apps use. The Python binding is PyGTK.
http://www.pygtk.org/ [snip] -- wxWindows is a lot like MS Windows MFC if I recall correctly.
The Python binding to wxWindows is called wxPython.
http://www.wxpython.org/


Note that wxWindows wraps native widgets, so a wxPython application
will use the native Windows widgets on windows, gtk widgets on
Linux/GNOME, Mac widgets on the Mac, etc.

I usually use wxPython for application development, but for my window
manager I'm using pygtk since it needs to be somewhat lower level and
portability to other platforms isn't a concern (turns out even that
isn't quite low-level enough for some things, so I drop down to
accessing the X event queue directly from C in a couple of cases).

Mar 2 '06 #10

P: n/a
On 2006-03-02, sj*******@yahoo.com <sj*******@yahoo.com> wrote:
Note that wxWindows wraps native widgets,


Not on Linux/KDE systems. ;)

--
Grant Edwards grante Yow! ANN JILLIAN'S HAIR
at makes LONI ANDERSON'S
visi.com HAIR look like RICARDO
MONTALBAN'S HAIR!
Mar 3 '06 #11

P: n/a
Grant Edwards wrote:
On 2006-03-02, sj*******@yahoo.com <sj*******@yahoo.com> wrote:
Note that wxWindows wraps native widgets,


Not on Linux/KDE systems. ;)


Right, I followed that with a clarification of supported systems. You
can use wxwindows with gtk-qt to get a Qt-ish look, although that's not
ideal.

The issue with wxqt is licensing; wxWindows is open-source, but not GPL
(it allows closed-source app development); gtk is LGPL'd so that's not
an issue, but Qt is GPL'd. Julian Smart (wxwindows developer)
contacted Troll for license clarifications but didn't get a response
(or not a useful one, I can't remember the specifics). There's no
ideological opposition to a qt implementation if the licensing can be
resolved (indeed they're willing to work with fully closed-source
toolkits, they just don't want to force application developers using
their toolkit to use a particular license).

Mar 3 '06 #12

P: n/a
Glurt Wuntal (02.03.2006 15:56):
I am a newbie with Python. It's a great language, but I would like to be
able to present a simple gui menu for some of my scripts; something better
than using 'raw_input' prompts.


If you only need some dialogs, input and/or message boxes, you could start
with EasyGUI.
http://www.ferg.org/easygui/

Matthias
Mar 3 '06 #13

P: n/a
Hi

I, too, am a python newbie and have wrestled with GUI programming. I
think I am winning, but its been a struggle.
From what I have gleaned, there are three and a half options. The half

is easygui - see http://www.ferg.org/easygui - which allows you to
place pop up dialogues in procedural code. Apart from that there's
Tkinter, PyGtk and wxPython. I never tried wxPython as it wasn't
installed on my system. I struggled with PyGtk (http://www.pygtk.org/)
and eventually gave up - somehow I could never get to work any code
which wasn't an exact copy of the tutorial. Which leaves Tkinter, and
here, with the help of Frederik Lundh's tutorial and manual
(http://www.pythonware.com/library/tkinter/introduction/) , I have been
able to get results. Not perfect - if you search you'll find a number
of my posts on this newsgroup when I was stuck, and the manual is
incomplete (why - given that Tkinter is the de facto standard?). But
for me at least Tkinter provided a way forwards.

Good Luck

Peter

Mar 3 '06 #14

P: n/a
On 3 Mar 2006 01:16:23 -0800, pe**********@talk21.com
I, too, am a python newbie and have wrestled with GUI programming. I
think I am winning, but its been a struggle.


I started with wxPython and struggled with it for a long time. I was
able to get the job done, but using it never seemed natural. Then I
found the Dabo project, whose ui module wraps wxPython into a much
more Pythonic, consistent interface. Since then I've been able to
create GUIs without much effort at all. I highly recommend Dabo if you
are thinking about wxPython.

--

# p.d.
Mar 3 '06 #15

P: n/a
In article <46************@uni-berlin.de>,
Matthias Huening <mh******@zedat.fu-berlin.de> wrote:
Glurt Wuntal (02.03.2006 15:56):
I am a newbie with Python. It's a great language, but I would like to be
able to present a simple gui menu for some of my scripts; something better
than using 'raw_input' prompts.


If you only need some dialogs, input and/or message boxes, you could start
with EasyGUI.
http://www.ferg.org/easygui/

Matthias

Matthias,

Thanks for pointing that out. I got EasyGUI and it works right out of
the box. Very nice for quick and dirty GUI stuff. Maybe some good
examples of using Tkinter, too. It is only version 0.72 and hasn't been
updated by the author since 2004. But it does work and is simple enough
that novice users like me might be able to maintain it and extend it.
Many thanks to the author (Stephen Ferg) for producing EasyGUI.

By the way it was written on a Windows machine and worked perfectly (so
far) on my Mac OS X machine.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
Mar 3 '06 #16

P: n/a
Another option would be FarPy GUIE: http://farpy.holev.com

Mar 4 '06 #17

P: n/a
On Fri, 3 Mar 2006 07:19:34 -0500, "Peter Decker" <py******@gmail.com>
wrote:
I started with wxPython and struggled with it for a long time. I was
able to get the job done, but using it never seemed natural. Then I
found the Dabo project, whose ui module wraps wxPython into a much
more Pythonic, consistent interface. Since then I've been able to
create GUIs without much effort at all. I highly recommend Dabo if you
are thinking about wxPython.


Dabo does look really nice, but seems like it has a ways to go yet.

I downloaded it a couple of weeks ago, and the very first thing I wanted
to do doesn't seem to be supported. I tried to create a simple
application with a Notebook control inside a frame. The Notebook
control doesn't appear to be supported yet.

Is that right, or am I just not looking in the right places?
Bill
Mar 4 '06 #18

P: n/a
On 3/4/06, Bill Maxwell <bi***************************@notreal.net> wrote:
Dabo does look really nice, but seems like it has a ways to go yet.

I downloaded it a couple of weeks ago, and the very first thing I wanted
to do doesn't seem to be supported. I tried to create a simple
application with a Notebook control inside a frame. The Notebook
control doesn't appear to be supported yet.

Is that right, or am I just not looking in the right places?


It's fully supported. Their generic term for these paged controls is a
'pageframe', so a wx.Notebook is their dPageFrame class; wx.Listbook
is their dPageList class; wx.Choicebook is their dPageSelect, and they
also have a page control with no tabs called (gasp!) dPageFrameNoTabs.
One thing that they've done is pick names for classes and properties
that are the most common for all toolkits instead of blindly following
the wx names.

All of these classes have the same interface, and respond to the same
events. IOW, they've unified these different classes so that they have
a single API, making working with them much easier.

--

# p.d.
Mar 4 '06 #19

P: n/a
On Sat, 4 Mar 2006 13:08:35 -0500, "Peter Decker" <py******@gmail.com>
wrote:
On 3/4/06, Bill Maxwell <bi***************************@notreal.net> wrote:
Dabo does look really nice, but seems like it has a ways to go yet.

I downloaded it a couple of weeks ago, and the very first thing I wanted
to do doesn't seem to be supported. I tried to create a simple
application with a Notebook control inside a frame. The Notebook
control doesn't appear to be supported yet.

Is that right, or am I just not looking in the right places?


It's fully supported. Their generic term for these paged controls is a
'pageframe', so a wx.Notebook is their dPageFrame class; wx.Listbook
is their dPageList class; wx.Choicebook is their dPageSelect, and they
also have a page control with no tabs called (gasp!) dPageFrameNoTabs.
One thing that they've done is pick names for classes and properties
that are the most common for all toolkits instead of blindly following
the wx names.

All of these classes have the same interface, and respond to the same
events. IOW, they've unified these different classes so that they have
a single API, making working with them much easier.

Thanks for the info. Knowing that, I was able to create a simple app in
the Dabo Designer that contains a Notebook.

But, I'm having a heck of a time finding any documentation at all on
Dabo. I looked all thru the website(s), and have combed the Dabo
software package itself.

Either I'm doing something wrong, or documentation is pretty sparse for
Dabo.

What little info I could find on the Dabo Wiki seems pretty old. I also
watched the two Sizer videos, but there's not enough info there to learn
much.

I read somewhere that they are concentrating on the User Interface
designer instead of the database aspects. The GUI maker is what I'm
interested in using, not the rest. I don't want to code the GUI
manually. Do you know where I can find more information on the
Designer?

Thanks,

Bill

Mar 5 '06 #20

P: n/a
On 3/5/06, Bill Maxwell <bi***************************@notreal.net> wrote:
Thanks for the info. Knowing that, I was able to create a simple app in
the Dabo Designer that contains a Notebook.

But, I'm having a heck of a time finding any documentation at all on
Dabo. I looked all thru the website(s), and have combed the Dabo
software package itself.

Either I'm doing something wrong, or documentation is pretty sparse for
Dabo.
No, you're not doing anything wrong. There isn't a whole lot of
documentation. That's one of the problems with projects being actively
developed: the developers are too busy with the development work to
step back and write the docs. They have asked for people to help out
if they can (it is open source, after all), but there hasn't been a
whole lot of that yet. I think a lot of people are like me: they have
figured out enough to make it work, and are doing some great stuff
with it, but don't feel that they know it enough to document it.
What little info I could find on the Dabo Wiki seems pretty old. I also
watched the two Sizer videos, but there's not enough info there to learn
much.
I have to agree. The videos are great, but so much more is needed. One
thing I can suggest is to post any questions on the dabo-users list.
Both the authors are very responsive and helpful.
I read somewhere that they are concentrating on the User Interface
designer instead of the database aspects. The GUI maker is what I'm
interested in using, not the rest. I don't want to code the GUI
manually. Do you know where I can find more information on the
Designer?


I think that the database side of things has been done for over a
year, and now they're looking to add support for more database types
as people start using it with other stuff. But as far as the GUI
Designer goes, I'd post questions on the dabo-users list.

--

# p.d.
Mar 6 '06 #21

P: n/a
If you are already familiar with html, you might consider using the
browser for the UI. It's pretty much cross-platform, if you ever need
that, and users are accustomed to browser look/feel.

If your installation doesn't already have a python-enabled http server
running, there are several options (python CGI scripts, cherrypy,
kerrigell), any one of which is easier to learn and more
generally-applicable (I think) than any of the gui toolkits.

Ron

Mar 6 '06 #22

P: n/a
On Mar 5, 2006, at 7:37 PM, Peter Decker wrote:
What little info I could find on the Dabo Wiki seems pretty old.
I also
watched the two Sizer videos, but there's not enough info there to
learn
much.


I have to agree. The videos are great, but so much more is needed. One
thing I can suggest is to post any questions on the dabo-users list.
Both the authors are very responsive and helpful.


<blush> Thanks for the compliment. Both Paul and I are very much
aware of the lack of documentation, but it feels like anything we
write now would become out-of-date quickly, since things (especially
in the visual tools area) are changing so rapidly. I am planning on
writing some documentation once the Class Designer and Menu Designer
are largely completed, because then it will be a while before the
next major change, as we look to integrate these tools into an IDE.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

Mar 6 '06 #23

This discussion thread is closed

Replies have been disabled for this discussion.