Fields

Pyface provides a small collection of simple field widgets that are pre-bound to a Traits interface, so that you can use them in a cross-toolkit manner.

Where possible, these classes share a common API for the same functionality. In particular, all classes have a value trait which holds the (usually user-editable) value displayed in the field. Code using the field can listen to changes in this trait to react to the user entering a new value for the field without needing to know anything about the underlying toolkit event signalling mechanisms.

All fields also provide traits for setting the tooltip and context_menu of the field. Tooltips expect unicode text values, and context menus should be MenuManager instances.

TextField

The ITextField interface provides additional traits that specify whether the value should be updated on every keystroke (by setting update_text to "auto") or when the user has finished editing the field by moving focus away from the text field (by setting update_text to "editing_finshed").

The text field can be set to show a placeholder text to hint about the desired value that is shown when the box is empty via the placeholder trait. It can also be set to conceal typed text by setting echo to "password" (and the Qt backend has a number of other options as well). The text field can be set to read-only mode via the read_only trait.

SpinField

The ISpinField interface has an integer for the value, and also requires a range to be set, either via setting the min/max values as a tuple to the range trait, or by setting values individually to minimum and maximum.

ComboField

The IComboField interface has an arbitrary value that must come from a list of valid values. For non-text values, a formatter function should be provided - this defaults to either str() (Python 3+) or unicode() (Python 2).

Table of Contents

Previous topic

Submodules

Next topic

Timers

This Page