PyGTK Shell, the "basically working" release

The PyGTK Shell is a framework making Python applications open to realtime programmatic intervention by its users.

This release should theoretically work on win32, but I didn't yet have the chance to test it. There have been many changes since I runned the last version on a win32 computer.

Please send feedback to: Felix Rabe <public@felixrabe.textdriven.com>

A screenshot for the curious and cautious

Screenshot

Requirements

Python 2.4.0 http://www.python.org/
or: http://www.activestate.com/Products/ActivePython/
PyGTK 2.8.0 http://www.pygtk.org/
PyWin32 http://sourceforge.net/projects/pywin32/ (only needed on MS Windows; included in ActivePython)

Download

pygtk-shell-basically-working-1.tar.gz (2006-Aug-05)

Installation

To install, just (view and) extract the archive somewhere. Stay in the created directory for experiments - there is no need to further install anything. Have a quick look at the source code if you're a bit paranoid.

Tutorial

Starting out

Start the shell from its directory:

  $ ./shell.pyw
(the .py extension worked better for me on win32)

You will get a window with the current directory, an empty output area, and tabs (Python, System, CD) providing different ways to enter commands.

Explore the Python environment by entering the following commands:

  >>> dir()
  ['Output', 'TextEditor', 'Window', '__builtins__', 'cairo',
  'cwd_changer', 'd', 'gobject', 'gtk', 'os', 'output', 'pango', 'python',
  'sys', 'system', 'window']

Ok, this is boring. Hit the "Up" key and find out that there's a history.

  >>> dir()
  ['Output', 'TextEditor', 'Window', '__builtins__', 'cairo',
  'cwd_changer', 'd', 'gobject', 'gtk', 'os', 'output', 'pango', 'python',
  'sys', 'system', 'window']

(At some point, try out the Shift-Return combination while in the history.)

You can enter multi-line statements:

  >>> for i in range(10):
  ...     print i
  ...
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9

This way, you can fill up the output area pretty quickly.

I'm bored

Create a window! The Window class (module pygsh.window) is derived from gtk.Window, you can use it to create a second (empty) PyGTK shell window:

  >>> win = Window()
  >>> win.set_keep_above(True)  # this is especially neat on win32...
  >>> win.set_title("My Own Window")

Pretty cool, eh? But still empty...

  >>> text = win.manager.manage(TextEditor())

Now that's MUCH less boring. By the way, the Window class has wonderful fullscreen support built in - just hit F11.

Text editing

The "System" and "CD" tabs provide system access - on the first, you can execute shell commands (like "ls -al" or "dir" on win32 with the .py file name extension), on the second you can change the current directory (this does have tab completion). Hint: Ctrl+Page Up/Down lets you change those contexts quickly without losing focus. (That's provided by gtk.Notebook.)

But before going there, enter another Python command:

  >>> system.output = text

This will make all the system commands' output go to the new window.

Try it out! In the "System" tab, enter the following command on Unix:

  $ ls -al

On Windows:

  $ dir

You can now mess around with the text editor and save your directory listing wherever you want. (No key bindings yet, you have to click.)

Changing directories

Let's do something with that "Current directory" display!

  >>> os.chdir("..")

This is too cumbersome, there should be a quicker way. By definition, a directory change is confined to the process where this happens. You can't just let a subprocess execute a "cd some/where/i/like" command and expect it to work like you want. But try the following:

  $ [Hit the "C" key] [Hit the "D" key and watch out] [Hit "Space"]

You're not on the "System" tab anymore! The "CD" tab lets you change the directory fairly easy (it features tab completion). When you're finished, the "CD" tab will pass the control back to the System tab. Whitespace is ignored as long as there is no text since on terminals it's common (on Unix, necessary) to hit the space key after the "cd" command.

Going home

You can close all the windows one by one - the last one closed will exit the PyGTK Shell. You can also close a window by typing Control-D if it contains a python / system / cd entry line. Entering "sys.exit()" in the Python tab will do what you expect.

The Future

See TODO.txt and help implement the features by sending patches!