473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Write a GUI for a python script?

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
22 5011
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
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
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
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
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
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
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
> 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
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
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
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
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
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
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
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
Another option would be FarPy GUIE: http://farpy.holev.com

Mar 4 '06 #17
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Werner Merkl | last post by:
Hi, Python is really great, for small to big programs. For my colleagues and some circumstances I sometimes need to "compile" a script using py2exe. Cause I use Windows, I like to use the...
3
by: Ali | last post by:
I have the following webpage with a javasctript in it: <html> <head> <title>Custom Objects Test</title> <script language="javascript"> function PrintCard() { line1 = "<hr>\n"; line2 =...
7
by: ckb2102 | last post by:
Hi there, I am new to this so I apologize in advance if I am not following the right etiquette or something... I am working on a project for school. My partner has written a short program in...
9
by: TPJ | last post by:
First I have to admit that my English isn't good enough. I'm still studying and sometimes I just can't express what I want to express. A few weeks ago I've written 'Python Builder' - a bash...
8
by: Alejandro | last post by:
Hi: I'm using pySerial to talk to a RS232 to RS485 converter. In order to control the converter, I need to control the DTR line to enable/disable de RS485 driver. In particular, I need to : ...
6
by: tatamata | last post by:
Hello. How can I run some Python script within C# program? Thanks, Zlatko
3
by: Matthew Warren | last post by:
I have the following piece of code, taken from a bigger module, that even as I was writing I _knew_ there were better ways of doing it, using a parser or somesuch at least, but learning how wasn't...
2
by: sophie_newbie | last post by:
Hi, I'm wondering if there is a way to get a python script to write text to an input box in a window of another program that is running? For example a text box in a web browser window? Thanks!
8
by: dmoore | last post by:
Hi folks, I've seen the following issue come up in multiple posts to this mailing list: I have a python program that spawns a child process with popen or popen2 or popen3 or popen2.popen2...
0
by: atulsharma84 | last post by:
i want to write a python script for a device NGX-5500 whose vendor is telllabs i hv to write python file like some other device file i m giving u example here below import java.lang as lang...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.