qpython - Introduction Next

qpython - a Qt-enabled Python shell

David Boddie

Introduction

One of the key benefits of the standard CPython interpreter is its support for interactive prototyping and experimentation. This gives developers the opportunity to evaluate different ways of solving problems that may be encountered during development.

Unfortunately, many graphical user interface (GUI) toolkits do not coexist well with this interactive use of Python. Most toolkits employ an approach that involves an event loop and callbacks; this usually means that the interpreter has to give up control to the toolkit, only to finally regain it when the application is exiting.

One solution to this problem is to run a simple command line interface to the Python interpreter in a separate thread to the GUI. This allows the toolkit to behave normally, and the developer to interact with it from a Python shell. With Qt, it is also necessary to execute all GUI-related tasks from the thread that is running the event loop.

qpython is an interactive shell that runs a QApplication event loop in one thread and a simple Python shell in another. This approach allows developers to experiment with Qt interactively, but has some limitations.


qpython - Introduction Next