pyface.ui_traits module¶
Defines common traits used within the pyface library.
-
pyface.ui_traits.
convert_image
(value, level=3)[source]¶ Converts a specified value to an ImageResource if possible.
-
pyface.ui_traits.
convert_bitmap
(image)[source]¶ Converts an ImageResource to a bitmap using a cache.
-
class
pyface.ui_traits.
Image
(value=None, **metadata)[source]¶ Bases:
traits.trait_type.TraitType
Defines a trait whose value must be a IImage or a string that can be converted to an IImageResource.
-
default_value
= None¶ Define the default value for the trait.
-
info_text
= 'an IImage or string that can be used to define an ImageResource'¶ A description of the type of value this trait accepts.
-
-
class
pyface.ui_traits.
PyfaceColor
(value=None, **metadata)[source]¶ Bases:
traits.trait_type.TraitType
A Trait which casts strings and tuples to a Pyface Color value.
-
default_value_type
= 7¶ The default value should be a tuple (factory, args, kwargs)
-
info
()[source]¶ 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.
PyfaceFont
(value=None, *, parser=<function simple_parser>, **metadata)[source]¶ Bases:
traits.trait_type.TraitType
A Trait which casts strings to a Pyface Font value.
-
default_value_type
= 7¶ The default value should be a tuple (factory, args, kwargs)
-
parser
= None¶ The parser to use when converting text to keyword args. This should accept a string and return a dictionary of Font class trait values (ie. “family”, “size”, “weight”, etc.).
-
info
()[source]¶ 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.
Margin
(*args, **traits)[source]¶ Bases:
pyface.ui_traits.BaseMB
-
class
pyface.ui_traits.
Border
(*args, **traits)[source]¶ Bases:
pyface.ui_traits.BaseMB
-
class
pyface.ui_traits.
HasMargin
(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]¶ 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
pyface.ui_traits.Margin
-
default_value
= <pyface.ui_traits.Margin object>¶ The default value for the trait type.
-
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'¶
-
-
class
pyface.ui_traits.
HasBorder
(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]¶ 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
pyface.ui_traits.Border
-
default_value
= <pyface.ui_traits.Border object>¶ The default value for the trait type.
-
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.
-
pyface.ui_traits.
Orientation
= Enum("vertical", "horizontal")¶ Whether the orientation of a widget’s contents is horizontal or vertical.