GUI Custom Option Boxes

Provides a collection of QWidget subclasses to be used as custom option entry boxes in the OptionsDialog class or KwargsDictDialogPage class.

class prism._gui.widgets.preferences.custom_boxes.ColorBox(*args, **kwargs)[source]

Defines the ColorBox class.

This class is used for making the ‘color’ entry in the KwargsDictDialogPage class.

__init__(*args, **kwargs)[source]

Initialize an instance of the ColorBox class.

Other Parameters:
 
  • args (positional arguments) – The positional arguments that must be passed to the constructor of the BaseBox class.
  • kwargs (keyword arguments) – The keyword arguments that must be passed to the constructor of the BaseBox class.
static convert_to_mpl_color(qcolor)[source]

Converts a provided QColor object color to a matplotlib color.

Parameters:qcolor (QColor object) – The instance of the QColor class must be converted to a matplotlib color.
Returns:color (str) – The corresponding matplotlib color. The returned color is always written in HEX.
static convert_to_qcolor(color)[source]

Converts a provided matplotlib color color to a QColor object.

Parameters:color (str) – The matplotlib color that must be converted. If color is a float string, an error will be raised, as Qt5 does not accept those.
Returns:qcolor (QColor object) – The instance of the QColor class that corresponds to the provided color.
create_color_combobox()[source]

Creates a combobox that holds all default colors accepted by matplotlib and returns it.

create_color_label()[source]

Creates a special label that shows the currently selected or hovered color, and returns it.

static create_color_pixmap(color, size)[source]

Creates a QPixmap object consisting of the given color with the provided size.

Parameters:
  • color (str) – The matplotlib color that must be used for the pixmap.
  • size (tuple) – The width and height dimension values of the pixmap to be created.
Returns:

pixmap (QPixmap object) – The instance of the QPixmap class that was created from the provided color and size.

get_box_value()[source]

Returns the current (valid) color value of the color combobox.

Returns:color (str) – The current valid matplotlib color value.
init()[source]

Sets up the color box entry after it has been initialized.

This function is mainly responsible for creating the color wheel and color label, that allow the user to quickly cycle through different color options.

set_box_value(value)[source]

Sets the current (default) color value to value.

Parameters:value (str) – The matplotlib color value that must be set for this colorbox.
set_color(color)[source]

Sets the current color to the provided color, and updates the entry in the combobox and the label accordingly.

This function acts as a Qt slot.

Parameters:color (str) – The color that needs to be used as the current color. The provided color can be any string that is accepted as a color by matplotlib. If color is invalid, it is set to the current default color instead.
set_color_label(color)[source]

Sets the current color label to the provided color.

This function acts as a Qt slot.

Parameters:color (str) – The color that needs to be used as the current color label. The provided color can be any string that is accepted as a color by matplotlib. If color is invalid, it is set to the current default color instead.
Returns:default_flag (bool) – Whether or not the color label is currently set to the default color. This happens when color is an invalid color.
show_colorpicker()[source]

Shows the colorwheel picker dialog to the user, allowing for any color option to be selected.

This function acts as a Qt slot.

class prism._gui.widgets.preferences.custom_boxes.ColorMapBox(*args, **kwargs)[source]

Defines the ColorMapBox class.

This class is used for making the ‘cmap’ entry in the KwargsDictDialogPage class.

__init__(*args, **kwargs)[source]

Initialize an instance of the ColorMapBox class.

Other Parameters:
 
  • args (positional arguments) – The positional arguments that must be passed to the constructor of the BaseBox class.
  • kwargs (keyword arguments) – The keyword arguments that must be passed to the constructor of the BaseBox class.
cmap_selected(cmap)[source]

Qt slot that checks a provided cmap and shows an error message if cmap is a terrible colormap.

static create_cmap_icon(cmap, size)[source]

Creates a QIcon object of the given cmap with the provided size.

Parameters:
  • cmap (Colormap object or str) – The colormap for which an icon needs to be created.
  • size (tuple) – A tuple containing the width and height dimension values of the icon to be created.
Returns:

icon (QIcon object) – The instance of the QIcon class that was created from the provided cmap and size.

get_box_value()[source]

Returns the current colormap of the colormap box.

Returns:cmap (Colormap object) – The currently selected colormap.
set_box_value(cmap)[source]

Sets the current colormap to cmap.

Parameters:cmap (Colormap object) – The colormap that must be used for this colormap box.
class prism._gui.widgets.preferences.custom_boxes.DefaultBox(*args, **kwargs)[source]

Defines the DefaultBox class.

This class is used for making a non-standard entry in the KwargsDictDialogPage class. It currently supports inputs of type bool; float; int; and str.

__init__(*args, **kwargs)[source]

Initialize an instance of the DefaultBox class.

Other Parameters:
 
  • args (positional arguments) – The positional arguments that must be passed to the constructor of the BaseBox class.
  • kwargs (keyword arguments) – The keyword arguments that must be passed to the constructor of the BaseBox class.
create_field_box(value_type)[source]

Creates a field box for the provided type value_type and replaces the current field box with it.

This function acts as a Qt slot.

Parameters:value_type ({‘bool’; ‘float’; ‘int’; ‘str’}) – The string that defines what type of field box is requested.
create_type_bool()[source]

Creates the field box for values of type ‘bool’ and returns it.

create_type_float()[source]

Creates the field box for values of type ‘float’ and returns it.

create_type_int()[source]

Creates the field box for values of type ‘int’ and returns it.

create_type_str()[source]

Creates the field box for values of type ‘str’ and returns it.

get_box_value()[source]

Returns the current value of the field box.

Returns:value (bool, float, int or str) – The current value of this default box.
init()[source]

Sets up the non-standard default box entry after it has been initialized.

This function is mainly responsible for creating the type combobox and allowing for different field boxes to be used for different value types.

set_box_value(value)[source]

Sets the value type to type(value) and the field value to value.

Parameters:value (bool, float, int or str) – The value to use for this default box. The type of value determines which field box must be used.