pyface.ui_traits module

Defines common traits used within the pyface library.

pyface.ui_traits.convert_image(value, level=3)

Converts a specified value to an ImageResource if possible.

pyface.ui_traits.convert_bitmap(image_resource)

Converts an ImageResource to a bitmap using a cache.

class pyface.ui_traits.Image(value=None, **metadata)

Bases: traits.trait_type.TraitType

Defines a trait whose value must be a ImageResource or a string that can be converted to one.

default_value = None
info_text = 'an ImageResource or string that can be used to define one'
validate(object, name, value)

Validates that a specified value is valid for this trait.

create_editor()

Returns the default UI editor for the trait.

class pyface.ui_traits.PyfaceColor(value=None, **metadata)

Bases: traits.trait_type.TraitType

A Trait which casts strings and tuples to a PyfaceColor value.

default_value_type = 7

The default value should be a tuple (factory, args, kwargs)

validate(object, name, value)
info()

Must return a string describing the type of value accepted by the trait handler.

The string should be a phrase describing the type defined by the TraitHandler subclass, rather than a complete sentence. For example, use the phrase, “a square sprocket” instead of the sentence, “The value must be a square sprocket.” The value returned by info() is combined with other information whenever an error occurs and therefore makes more sense to the user if the result is a phrase. The info() method is similar in purpose and use to the info attribute of a validator function.

Note that the result can include information specific to the particular trait handler instance. If the info() method is not overridden, the default method returns the value of the ‘info_text’ attribute.

class pyface.ui_traits.BaseMB(*args, **traits)

Bases: traits.has_traits.ABCHasStrictTraits

class pyface.ui_traits.Margin(*args, **traits)

Bases: pyface.ui_traits.BaseMB

class pyface.ui_traits.Border(*args, **traits)

Bases: pyface.ui_traits.BaseMB

class pyface.ui_traits.HasMargin(default_value=<traits.trait_type.NoDefaultSpecified object>, **metadata)

Bases: traits.trait_type.TraitType

Defines a trait whose value must be a Margin object or an integer or tuple value that can be converted to one.

klass

alias of Margin

default_value = <pyface.ui_traits.Margin object>
info_text = 'a Margin instance, or an integer in the range from -32 to 32 or a tuple with 1, 2 or 4 integers in that range that can be used to define one'
validate(object, name, value)

Validates that a specified value is valid for this trait.

get_default_value()
Returns a tuple of the form:

(default_value_type, default_value)

which describes the default value for this trait.

class pyface.ui_traits.HasBorder(default_value=<traits.trait_type.NoDefaultSpecified object>, **metadata)

Bases: pyface.ui_traits.HasMargin

Defines a trait whose value must be a Border object or an integer or tuple value that can be converted to one.

klass

alias of Border

default_value = <pyface.ui_traits.Border object>
info_text = 'a Border instance, or an integer in the range from 0 to 32 or a tuple with 1, 2 or 4 integers in that range that can be used to define one'
pyface.ui_traits.Position = Enum("left", "right", "above", "below")

The position of an image relative to its associated text.

pyface.ui_traits.Alignment = Enum("default", "left", "center", "right")

The alignment of text within a control.