PyConsole 0.1

PyConsole is a PyGTK widget that exposes a Python console using a TextView widget.
PyConsole is a PyGTK widget that exposes a Python console using a TextView widget. It runs on all gtk-supported platforms and features completion and history. PyConsole's expected use case is to be embedded and used to inspect other applications internals.

This module 'runs' python interpreter in a TextView widget. The main class is Console, usage is:

Console(locals=None, banner=None, completer=None, use_rlcompleter=True, start_script='') - it creates the widget and 'starts' interactive session; see the end of this file. If start_script is not empty, it pastes it as it was entered from keyboard.

Console has "command" signal which is emitted when code is about to be executed. You may connect to it using console.connect or console.connect_after to get your callback ran before or after the code is executed.

To modify output appearance, set attributes of console.stdout_tag and console.stderr_tag.

Console may subclass a type other than gtk.TextView, to allow syntax highlighting and stuff, e.g.:

console_type = pyconsole.ConsoleType(moo.edit.TextView)
console = console_type(use_rlcompleter=False, start_script="import moonimport gtkn")

This widget is not a replacement for real terminal with python running inside: GtkTextView is not a terminal. The use case is: you have a python program, you create this widget, and inspect your program interiors.

last updated on:
April 18th, 2008, 5:52 GMT
developed by:
Yevgen Muntyan
license type:
GPL (GNU General Public License) 
ROOT \ Programming \ Widgets


In a hurry? Add it to your Download Basket!

user rating 19



Add your review!