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.-
static
convert_to_mpl_color
(qcolor)[source]¶ Converts a provided
QColor
object color to a matplotlib color.Parameters: qcolor ( QColor
object) – The instance of theQColor
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 theQColor
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 theQPixmap
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.
-
static
-
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:
-
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 theQIcon
class that was created from the provided cmap and size.- cmap (
-
-
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:
-
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.
-
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.
-