Fetching contributors…
Cannot retrieve contributors at this time
83 lines (56 sloc) 2.42 KB

TraitsUI: Traits-capable windowing framework

The TraitsUI project contains a toolkit-independent GUI abstraction layer, which is used to support the "visualization" features of the Traits package. Thus, you can write model in terms of the Traits API and specify a GUI in terms of the primitives supplied by TraitsUI (views, items, editors, etc.), and let TraitsUI and your selected toolkit and back-end take care of the details of displaying them.

The following GUI backends are supported:

  • PyQt
  • wxPython
  • PySide

Warning: In TraitsUI version 5.0 the default GUI backend was changed from wx to qt4.


Given a Traits model like the following:

from traits.api import HasTraits, Str, Range, Enum

class Person(HasTraits):
    name = Str('Jane Doe')
    age = Range(low=0)
    gender = Enum('female', 'male')

person = Person(age=30)

we can use TraitsUI to specify a and display a GUI view:

from traitsui.api import Item, RangeEditor, View

person_view = View(
    Item('age', editor=RangeEditor(mode='spinner')),
    buttons=['OK', 'Cancel'],


which creates a GUI which looks like this:


If you want to run traitsui, you must also install:

along with one of the GUI backends.

Running the Test Suite

To run the test suite, install `Invoke`_ and `EDM`_ and follow the instructions in In particular:

> invoke test_all

will run tests in all supported environments automatically.