[pygtk] PyGTK Shell "basically working" release

Felix Rabe (public) public at felixrabe.textdriven.com
Tue Aug 8 21:53:38 WST 2006


Hi John,

I've had a look at IPython.  It is certainly a worthwile Python shell 
replacement, and in your case might be the better option.  But as a 
PyGTK Shell alternative, the following points hit me:

- It needs PyReadline on Windows, which I don't find documentation for, 
looking at 
http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro .  And 
it adds ctypes (which is nice to have included in Python 2.5) as a 
further dependency.

- The user is expected to fine-tune because of the many features.

- In a quick test, "%bg gtk.main()" brought me to a blocking mode when 
trying to access any variable.  Probably because of the global 
interpreter lock.

PyGTK Shell requires "just" Python 2.4 (no ctypes included nor 
required), PyWin32 on win32 (also a req. of IPython), doesn't (yet) have 
that many features that need to be configured (and if, it would provide 
a configuration GUI), and the GTK main loop is active anyway, so there 
is no lock-up.

John Pye wrote:
 > Hi Felix
 >
 > I'd appreciate if you could clarify what (if any) connections exist
 > between this new project of yours and the ipython project and the
 > xterm and/or gnome-terminal programs.

No connections at all. My main "design" criterias are:

- Program components should be completely accessible from Python.  The 
primary purpose of PyGTK Shell (where it should excel) is user-friendly 
interactive scriptability of PyGTK applications.

- Compatible with / using (Py)GTK.

- As few dependencies as possible outside PyGTK.  (Currently just 
PyWin32 on Windows.)

- Portable, especially to win32 - no cygwin desired.  (Frankly too big.)

- Usable easily and efficiently. (I'm a Blender fan especially regarding 
it's productive usability.)

To your question:

ipython - See above.

xterm - I've run that using cygwin once, other than that it's not 
looking like ported to win32.

gnome-terminal - is bound to GNOME and not (win32) portable. I would 
like to use vte (see HACKING.txt) for terminal stuff, but then, that's 
not been (natively) ported yet, either.

 > Does it support xterm colour codes? What about cursor positioning
 > codes? Can I run a bash shell via this popup window, or only a python
 > shell? Does it provide native GNU readline support or have you coded
 > your own take on that?

The goal of PyGTK Shell's "System" prompt is not a complete terminal. It 
should be usable to call stuff like compilation commands (make and 
friends) and to directly insert (stdout) output to its text editor. 
Based on the subprocess module, it uses the system's default shell (sh 
on Unix, cmd on Windows). Providing stdin to programs is currently not 
supported, but this might be added (for simple "nl > numbered-file.txt" 
kind of stuff), provided an idea on how to tackle this in a 
user-friendly way. Support for bash or (other) curses-based applications 
or color codes is out of scope. I mostly use the PyGTK Shell's "System" 
prompt on win32 where the provided DOS command line drives me nuts. I 
use a custom launcher script there (shell.pyw) that includes often-used 
commands in the history and jumps to the first one.

On my own computer (Ubuntu Linux), I just use Gnome Terminal when not 
using Python.

The Python shell ("Python" tab) on the other hand is based on the 
gtkcons.py pygtk example (see CREDITS.txt), enhanced here and there. It 
is basically an interactive Python shell separate from the command line 
shell, providing a history (yes, my own take) and multiline statement 
support. Python does have a readline module, but: "Availability: Unix."

 > My feeling tends to be that in an application such as this one should
 > be providing the means to interface with already-existing terminal
 > program, rather than implementing a whole new one, but then perhaps
 > that is what you're doing here.

That's not my intent. An idea would be to make the PyGTK Shell usable as 
a server that can be called from a terminal (similar to "python -c ...") 
to have it execute Python statements or to pass it some command's output 
or a file for inclusion in a TextEditor widget. But I didn't yet think 
about where I would want to be able to use a networked PyGTK Shell and 
why I would want to use it this way. BTW, I'm reading a textbook on 
network security, so I'm not really all that excited about this idea (o;

Greetings,
Felix



More information about the pygtk mailing list