Naming and coding conventions -- X Python Reference Manual

Next: Drawing Prev: Introduction Up: Introduction Top: Top

# 1.1. Naming and coding conventions

Prefixes, such as `Xt`, `Xm`, and `Glx` are dropped from a function name.

Only Xt functions that have no widget or widget class argument are defined directly in the Xt module.

`XtInitialize` must be called as `Xt.Initialize('classname', [], sys.argv)` or as `Xt.Initialize()`.

Xt and Xm functions with a widget parameter are changed into widget methods, with the widget parameter removed, even if it is not the first parameter.

Xt functions with a widget class parameter are changed into widget class methods.

Parameters, return values, and resources of type `XmString` are replaced by ordinary Python strings.

Parameters representing structures are replaced by Python tuples.

Some functions accept a partially filled struct with a flag describing which members are filled in. This is represented by a dictionary where the key is the name of the struct members to be filled in, and the value the value of these members. No flag is used.

Pairs of parameters describing arrays of strings or structures are replaced by a Python list of strings or tuples.

Output parameters are always replaced by Python function return values. If there is more than one output parameter, a tuple is constructed. If the functions also returns a value, it is the first element of the tuple.

Input parameters of type `ArgList`, such as those given to `XtCreateWidget` and `XtSetValues`, are replaced by a dictionary with the resource name as key and the resource value as value. Also, the return value of `XtGetValues` is such a dictionary.

Functions in Xlib that take both a Display and a Window argument are implemented as widget methods (if they are implemented at all). The Display and Window arguments are then removed from the argument list.

Next: Drawing Prev: Introduction Up: Introduction Top: Top