Building an Interactive Console

Now we have everything needed to create a basic interactive console. We implemented this as an extra child window with a one-line text box for input and a multiline, uneditable text box for output. When the user inputs an expression, the VB console form executes the commands TheBookServer.interpretString ( expression ) to get the return value and TheBookServer.getStandardOutput to retrieve any output that was generated. It then assembles these together into one chunk of text and appends this to the output text box. Figure 8.1 is an example of our console in action.

A crude Python console
Figure 8.1. A crude Python console

Note you have full access to the data of your running server and can modify its data. You can also create your own variables and generally do anything you can from a regular Python console.

Get Python Programming On Win32 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.