Defines various helper functions that are useful for creating Traits-based user interfaces.
Formats a specified value as an integer string with embedded commas. For example: commatize( 12345 ) returns “12,345”.
compute_column_widths(available_space, requested, min_widths, user_widths)¶
Distribute column space amongst columns based on requested space.
Widths requests can be specified as one of the following:
a value greater than 1.0 is treated as a fixed width with no flexibility (ie. a minimum width as specified and a weight of 0.0)
a value between 0.0 and 1.0 is treaded as a flexible width column with the specified width as a weight and a minimum width provided by the min_widths entry.
a value less than or equal to 0.0 is treated as a flexible width column with a weight of 0.1 and a minimum width provided by the min_widths parameter.
If user widths are supplied then any non-None values override the requested widths, and are treated as having a flexibility of 0.
Space is distributed by evaluating each column from smallest weight to largest and seeing if the weighted proportion of the remaining space is more than the minimum, and if so replacing the width with the weighted width. The column is then removed from the available width and the total weight and the analysis continues.
available_space (int) – The available horizontal space.
requested (list of numbers) – The requested width or weight for each column.
min_widths (None or list of ints) – The minimum width for each flexible column
user_widths (None or list of int or None) – Any widths specified by the user resizing the columns manually.
widths – The assigned width for each column
- Return type
list of ints
enum_values_changed(values, strfunc=<class 'str'>)¶
Recomputes the mappings for a new set of enumeration values.
Returns a “user-friendly” name for a specified trait.