The TraitsUI package is a set of user interface tools designed to complement Traits. In the simplest case, it can automatically generate a user interface for editing a Traits-based object, with no additional coding on the part of the programmer-user. In more sophisticated uses, it can implement a Model-View-Controller (MVC) design pattern for Traits-based objects.
"The brilliance of TraitsUI is that you don't really have to think about the mapping between model and UI. You can concentrate on the model, and the UI automatically reflects changes to the model ... and vice versa."
— Danny Shevitz, Los Alamos NM
NOTE: While the TraitsUI API is included in the Traits project, in order to display a user interface, you need to also get the TraitsUI project, a Python UI toolkit, and the corresponding Traits "backend" project. See the TraitsUI page for details.
If you want to display Traits-based user interfaces, you need, in addition to the Traits project:
- The TraitsUI project
- A Python UI toolkit, either wxPython or PyQt
- A "backend" connector, either TraitsBackendWX or TraitsBackendQt
The TraitsUI project contains a toolkit-independent UI abstraction layer (known as Pyface), which is used to support the "visualization" features of the Traits package. Thus, you can write code in terms of the Traits API (view, items, editors, etc.), and let TraitsUI and your selected toolkit and backend take care of the details of displaying them.
Pyface enables programmers to interact with generic UI objects, such as an "MDI Application Window", rather than with raw UI widgets. (Pyface is named by analogy to JFace in Java.) Traits uses Pyface to implement views and editors for displaying and editing Traits-based objects.
Traits and Pyface define APIs that are independent of any UI toolkit. However, in order to actually produce user interfaces with them, you must install a supported Python-based UI toolkit and the appropriate toolkit-specific backend project. Conversely, if you wish to use Traits without a UI, a "null" backend is automatically used in the absence of a real backend.
Currently, the supported UI toolkits are wxPython and PyQt. While both toolkits funtion with Traits, integration with wxPython is currently more complete. All future development, however, will focus on supporting PyQt.