Chapter 28. Python

Table of Contents
28.1. The TextWindow
28.2. Python for games
28.3. Game Python Documentation per module
28.4. Standard methods for LogicBricks

Python is an interpreted, interactive, object-oriented programming language.

Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. Python is also usable as an extension language for applications that need a programmable interface.

Beside this use as an extension language, the Python implementation is portable to (at least) all platforms that Blender runs on.

Python is copyrighted but freely usable and distributable, even for commercial use.

28.1. The TextWindow

The TextWindow is a simple but useful text editor, fully integrated into Blender. It's main purpose of it is to write Python scripts, but it is also very useful for writing comments in the Blendfile or to explain the purpose of the scene to other users.

Figure 28-1. The TextWindow

The TextWindow can be displayed with SHIFT-F11 or by adjusting the IconMenu in the WindowHeader. As usual there is an IconBut to make the TextWindow fullscreen, the next MenuButton can be used to switch between text files, open new ones or add new text buffers. The "X"-shaped Button deletes a textbuffer after a confirmation.

With the MenuButton on the right side you can change the font used to display the text.

By holding LMB and then dragging the mouse you can mark ranges of text for the usual cut, copy & paste functions. The key commands are:

Keycommands for the TextWindow


Copies the marked text into a buffer


Cuts out the marked text into a buffer


Pastes the text from buffer to the cursor in the TextWindow


Loads a text, a FileWindow appears


Reloads the current text, very useful for editing with an external editor


Pops up the Filemenu for the TextWindow


Find function


Pops up a NumButton where you can specify a line number that the cursor will jump to


Unlimited Undo for the TextWindow


Redo function, recovers the last Undo


Marks the whole text