# Framework Overview - Runtime Tools

Updated: March 31, 2006 for release 0.8.2

PythonCard supports the following runtime tools (command-line switch in parens).

      Debug            (-d) <- Enable a debug menu, but don't show any windows.
      Log              (-l)
      Message Watcher  (-m)
      Namespace Viewer (-n)
      Property Editor  (-p)
      Shell            (-s)

The Log facility is defined in log.py. The other runtime tools or their wrappers are in debug.py. All of the runtime tool windows are children of the parent app window, so they don't show up on the taskbar under Windows. In addition, if one of the windows is created at startup, then all of the tools are initialized and available via the Debug menu, otherwise they are not initialized or available and apps don't incur any startup or memory overhead from the runtime tools.

All of the runtime windows are done in raw wxPython and their events will not interfere or show up in the main app event loop. It would be preferable for the windows to be defined just like other PythonCard backgrounds/windows, to simplify controlling them from a PythonCard app and to help with their longer-term maintenance.

The runtime tool window positions, sizes, and whether they are shown by default is defined in the pythoncard_config.txt file. You can save your settings to pythoncard_config.txt from the Debug menu.

You can redirect stdout (print statements) to the shell and back to the console at any time while an app is running.

The Namespace Viewer and Shell are provided by PyCrust which is a standard part of the wxPython distribution and not part of the PythonCard framework. The Namespace Viewer shows the local application namespace.

The Message Watcher shows all of the events generated and handled by components in PythonCard. Unused events are shown in parens (). Idle events are not shown.

The Property Editor allows editing of component attributes (properties). Only those attributes that are read-only can't be changed and usually that is because the attribute can only be set during initialization. The Property Editor in the resourceEditor is modeled on the runtime Property Editor, but is actually just another PythonCard background and provides more control than the runtime Property Editor, which is why it has a slightly different name, "resourceEditor Property Editor".

The Shell is the most powerful way that you can interact with a PythonCard application at runtime. The shell uses the Python interpreter, so all the things you can do at the Python interactive prompt at the command-line or in an IDE like IDLE can be done in a PythonCard app at runtime.

The shell automatically loads a series of commands when it starts up:

    shell.autoCompleteIncludeMagic = True
    shell.autoCompleteIncludeSingle = False
    shell.autoCompleteIncludeDouble = False
    shell.autoCompleteWxMethods = False

    import os
    import sys
    # workaround for absolute pathnames
    # in sys.path (see model.py)
    if sys.path[0] not in ('', '.'):
        sys.path.insert(0, '')

    import wx
    from PythonCard import dialog, util
    bg = pcapp.getCurrentBackground()
    self = bg
    comp = bg.components

These commands are in a pycrustrc.py file in the framework directory. You can also have a pycrustrc.py file in a PythonCard application directory (see the turtle sample). There have been numerous messages on the list showing how to add and interact with components at runtime. You can also define methods at runtime.

The Shell supports command-completion and tool tips, so it is very nice for interactive programming, learning and testing PythonCard. Again, the turtle sample is a good example of using the shell. Since the shell is provided via PyCrust, most of these features aren't limited to just PythonCard, but PythonCard probably makes the most and best use of PyCrust right now.

| General Concepts and Limitations | Components | Dialogs | Events and Handlers | Menus | Resource Files | Runtime Tools

$Revision: 1.4 $ : $Author: alextweedly $ : Last updated $Date: 2006/04/06 11:00:26 $