Pythonwin GUI Environment¶
Existing document
\Pythonwin\doc\guienvironment.html
This document describes the Pythonwin GUI environment. There are quite a few little features hidden away!
It has a discussion on the General Environment and the Command Line Arguments supported.
Interactive Window¶
The Interactive Window is a little Python program which simulates the built-in Python interpreter. It is implemented in intpyapp.py (which in turn uses winout.py
- a general purpose “output window”.)
Pressing Enter¶
Whenever you press Enter, the interactive window has a look at the context, to try and decide what to do.
If the line is recognised as a “block” (ie, the first line starts with “>>> “, and the rest start with “… “), it checks to see if we are at the end of the window. If not, the block is copied to the end of the buffer - nothing is executed - enter must be pressed again to force execution.
If we are at the end of the buffer, it always attempts to execute the line. If Python indicates “unexpected end of file”, then it assumes the block should continue, and emits the “… “ for the next line.
If the line is recognised as part of a Python exception, then some special processing is done. If the line contains a filename and line number, it locates that file, and jumps to the offending line.
If the line is recognised as being an exception generated by COM (aka OLE), and the exception contains reference to a WinHelp file, the help topic is opened.
Command Line Arguments¶
The following command line arguments are recognised. Note that these are implemented in “intpyapp.py”, so should be pretty easy to change!
/new (deprecated)/nodde Creates a new instance of the application even if one is already running.
/edit filename Edit the named file.
/run scriptname args Runs the named script. Works just like “Python.exe scriptname args”, except it is run in the GUI environment, and output goes to the interactive window.
/rundlg scriptname args As above, except the normal Pythonwin ‘Run Script’ dialog is shown.
/edit filename.py Edits the filename. The /edit is currently optional, but in the future, the “default argument handling” may be changed.
/app specialscriptname args
Runs a special “application script”. The application script can change the entire look and feel of a Pythonwin program - almost as much flexibility as the C++ programmer has when they first start their application). An example of this is dlgapp.py
in the Pythonwin distribution.