Widgets

SpinSlider

class datavis.widgets.SpinSlider(parent=None, **kwargs)

Custom widget that contains a Slider and also a Spinbox. Both components will have the same range and the values will be synchronized.

__init__(parent=None, **kwargs)

Create a new SliderSpin instance.

Parameters

parent – Parent QWidget.

Keyword Arguments
  • text – (str) Optional text to be used as label of the Widget

  • minValue – (int/float) The minimum value to be shown

  • maxValue – (int/float) The maximum value to be shown

  • currentValue – (int/float) The currentValue

getRange()

Return a tuple (minimum, maximum) values

getText()

Returns the label text for the internal slider

getValue()

Return the current value. (Same in both the slider and the spinbox).

setFocusPolicy(self, Qt.FocusPolicy)
setRange(minValue, maxValue)

Set the minimum and maximum values :param minimum: (int) The minimum possible value :param maximum: (int) The maximum possible value

setText(text)

Set the label text for the internal slider :param text: (str) The text

setValue(value)

Set a new value.

sigValueChanged

Emitted when the user releases the slider.

ZoomSpinBox

class datavis.widgets.ZoomSpinBox(parent=None, **kwargs)

Custom widget that contains a Loupe icon and a Spinbox. The SpinBox will handle the zooming of images in a given range.

__init__(parent=None, **kwargs)

Create a new ZoomSpinBox instance.

Parameters

parent – Parent QWidget.

Keyword Arguments
  • valueType – (int) The type for the spinbox values: TYPE_REAL or TYPE_INT. Default type: TYPE_INT

  • minValue – (int) The minimum value to be shown

  • maxValue – (int) The maximum value to be shown

  • currentValue – (int) The currentValue

  • zoomUnits – (int) The units

getUnits()

Return the zoom units. Possible values are: PIXELS and PERCENT

IconSpinBox

class datavis.widgets.IconSpinBox(parent=None, **kwargs)

Custom widget that contains a Icon and a Spinbox.

__init__(parent=None, **kwargs)

Create a new IconSpinBox instance.

Parameters

parent – Parent QWidget

Keyword Arguments
  • valueType – (int) The type for the spinbox values: int or float

  • minValue – (int) The minimum value to be shown

  • maxValue – (int) The maximum value to be shown

  • currentValue – (int) The currentValue

  • iconName – (str) The icon name

  • iconSize – (int) The icon size in pixels

  • suffix – (str) The suffix is appended to the end of the displayed value

  • prefix – (str) The prefix is prepended to the start of the displayed value

getRange()

Return a tuple (minimum, maximum) values

getValue()

Return the current value. (Same in both the slider and the spinbox).

setFocusPolicy(self, Qt.FocusPolicy)
setRange(minimum, maximum)

Set the minimum and maximum values :param minimum: (int) The minimum possible value :param maximum: (int) The maximum possible value

setValue(value)

Set a new value.

AxisSelector

class datavis.widgets.AxisSelector(parent=None, orientation=0, label='Axis: ', xlabel='X', ylabel='Y', zlabel='Z')

Custom widget for axis selection. Show a label text in the left side, and the axis for selection.

__init__(parent=None, orientation=0, label='Axis: ', xlabel='X', ylabel='Y', zlabel='Z')

Create a new AxisSelector instance. :param parent: The parent widget :param label: (str) A label text for the widget :param xlabel: (str) The label text for X-axis :param ylabel: (str) The label text for Y-axis :param zlabel: (str) The label text for Y-axis

HORIZONTAL = 0

This value is used to signify an vertical orientation

SHOW_CURRENT = 2

This value is used to show all axis

VERTICAL = 1

This value is used to show only the current axis

getCurrentAxis()

Return the current axis: AXIS_X, AXIS_Y or AXIS_Z

setCurrentAxis(axis)

Sets the current axis. Possible values: AXIS_X, AXIS_Y, AXIS_Z

setViewMode(mode)

Set the view mode. :param mode: (int) Specify the view mode: SHOW_CURRENT or SHOW_ALL

sigAxisChanged

This value is used to signify an horizontal orientation

ParamWidget

class datavis.widgets.ParamWidget(param, parent=None)

ParamWidget is the base class for all Params-Widgets. A parameter is an abstract entity defined by a basic properties of a parameter to be used in different context

__init__(param, parent=None)

Construct a ParamWidget instance

Parameters
  • paramParam

  • parent – The parent widget

emitValueChanged(paramValue)

Emits the sigValueChanged signal

get()

Return the param value for this widget. Need to be reimplemented in subclasses

set(value)

Set the param value. Need to be reimplemented in subclasses.

OptionsWidget

class datavis.widgets.OptionsWidget(param, parent=None)

The OptionsWidget provides a means of presenting a list of options to the user. The display param specify how the options will be displayed.

__init__(param, parent=None)

Construct an OptionsWidget

Parameters
  • paramParam

  • parent – The parent QWidget

get()

Reimplemented from ParamWidget

set(value)

Set the given option as selected. Reimplemented from ParamWidget

TextWidget

class datavis.widgets.TextWidget(param, parent=None)

The TextWidget is a one-line text editor.

__init__(param, parent=None)

Construct an TextWidget instance.

Parameters
  • paramParam

  • parent – The parent widget

get()

Reimplemented from ParamWidget.

Returns

The current text

set(value)

Reimplemented from ParamWidget. Set the given value as the current text.

NumericWidget

class datavis.widgets.NumericWidget(param, parent=None)

The NumericWidget is a one-line numbers editor. It supports the following types: integer, float

__init__(param, parent=None)

Construct a ParamWidget instance

Parameters
  • paramParam

  • parent – The parent widget

BoolWidget

class datavis.widgets.BoolWidget(param, parent=None)

ParamWidget subclass that wraps a Param with ‘bool’ type.

__init__(param, parent=None)

Construct an BoolWidget instance. :param param: Param :param parent: The parent widget

get()

Reimplemented from ParamWidget

set(value)

Reimplemented from ParamWidget

ButtonWidget

class datavis.widgets.ButtonWidget(param, parent=None)

ParamWidget subclass that wraps a Param with ‘button’ type.

__init__(param, parent=None)

Construct an BoolWidget instance. :param param: Param :param parent: The parent widget

get()

Return the param value for this widget. Need to be reimplemented in subclasses

set(value)

Set the param value. Need to be reimplemented in subclasses.

FormWidget

class datavis.widgets.FormWidget(form, parent=None, name='')

The FormWidget is the container widget for a ordered group of Params

__init__(form, parent=None, name='')

Construct an FormWidget instance

Parameters
  • formForm instance with the definition of the params.

  • parent – The parent widget

  • name – (str) The container name

getParamValues()

Return a dict with the value of each of the input params. The key of each item will be the param’s name and the value the current value from the GUI.

PagingInfo

class datavis.widgets.PagingInfo(numberOfItems, pageSize, currentPage=1)

Very simple class to store information about paging logic of a group of items (usually rows) and ease some calculations.

__init__(numberOfItems, pageSize, currentPage=1)

Construct a PagingInfo instance.

Parameters
  • numberOfItems – (int ) Total number of items that will be taken into account for paging.

  • pageSize – (int) Number of items will be in one page.

  • currentPage – (int) Current page (first page is 1).

getPage(index)

Return the page where index are located or -1 if it can not be calculated.

Parameters

index – (int) The index. 0 is the first

Returns

(int) The page index. 0 is the first

isLastPage()

Returns True if the current page is the last.

nextPage()

Increase the current page by one. If the current page is the last one, it will not be changed. Return True if the currentPage was changed.

prevPage()

Decrease the current page by one. If the current page is 1, it will not be changed. Return True if the currentPage was changed.

setCurrentPage(value)

Set the current page.

Parameters

value – (int) The page number(1 is the first).

Returns

True if the current page is changed.

setPageSize(pageSize)

Sets the page size. Changing the page size implies changing the current page.

Parameters

pageSize – (int) The number of items per page

PageBar

class datavis.widgets.PageBar(parent=None, **kwargs)

Paging bar that will allow users to navigate through pages

__init__(parent=None, **kwargs)

Construct an PageBar instance

Parameters

parent – Parent widget

Keyword Arguments

pagingInfoPagingInfo

getCurrentPage()

Returns the current page

getPageCount()

Returns the number of pages

setCurrentPage(page)

Sets page as current page. Emits the sigPageChanged signal

setPagingInfo(pagingInfo, step=1)

Setups the paging params

sigPageChanged

This signal is emitted when the paging info is changed

ViewPanel

class datavis.widgets.ViewPanel(parent, layoutType=0)

The ViewPanel contains widgets organized according to the specific layout:

  • HORIZONTAL: Horizontal layout,

  • VERTICAL: Vertical layout,

  • GRID: Grid layout,

  • HSPLITTER: Horizontal splitter,

  • VSPLITTER: Vertical splitter.

__init__(parent, layoutType=0)

Construct an ViewPanel instance

Parameters
  • parent – The parent widget

  • layoutType – The layout type

GRID = 2

Lays out widgets in a horizontal splitter

HORIZONTAL = 0

Lines up widgets vertically

HSPLITTER = 3

Lays out widgets in a vertical splitter

VERTICAL = 1

Lays out widgets in a grid

addWidget(widget, key, alignment=<PyQt5.QtCore.Qt.Alignment object>, row=-1, col=-1)

Add a widget to the internal layout

Parameters
  • widget – (QWidget) The widget

  • key – Unique key for the widget

  • alignment – (Qt.Alignment) The alignment for the widget. Default value is Qt.AlignCenter

  • row – (int) Add the widget at row ‘row’ if layout is GRID

  • col – (int) Add the widget at column ‘col’ if layout is GRID

getWidget(key)

Return the widget inserted with the given key

TextView

class datavis.widgets.TextView(parent=None, showLines=True)

Provides a widget that is used to edit and display plain text. TextView can read the text lines from a file input stream and show only the first and last lines specified.

__init__(parent=None, showLines=True)

Initialize self. See help(type(self)) for accurate signature.

clear()

Deletes all the text in the text edit.

isReadOnly()

Return True if the text edition is in read-only mode

readText(inputStream, firstLines, lastLines, separator='.')

Read text lines from the given input stream and show the first ‘firstLines’ lines and the last ‘lastLines’ using a separator between the text blocks. :param inputStream: A file input stream :param firstLines: The number of first lines to be shown :param lastLines: The number of last lines to be shown :param separator: The lines range separator

setHighlighter(highlighter)

Set the document highlighter

setLinesWrap(w)

Enable/disable the lines wrap mode :param w: (bool) The lines wrap

setReadOnly(ro)

Set the text edition as read-only if ro is True.

setText(text)

Sets the plain text editor’s contents

Parameters

text – (str) The text

ActionsToolBar

class datavis.widgets.ActionsToolBar(parent, **kwargs)

Toolbar that can contain a drop-down panel with additional options. Actually, only the Qt.Vertical mode is supported.

__init__(parent, **kwargs)

Construct an ActionsToolBar to be used as part of any widget

Parameters

parent – The parent widget

Keyword Arguments
  • orientation – one of Qt.Orientation values (default=Qt.Horizontal)

  • panelMinWidth – (int): the minimum side panel width

  • panelMaxWidth – (int): the maximum side panel width

addAction(action, widget=None, index=None, exclusive=True, showTitle=True, checked=False, floating=False)

Add a new action with the associated widget(side panel). This widget will be shown in the side panel when the action is active. If exclusive=True then the action will be exclusive respect to other actions. if showTitle=True then the action text will be visible as title in the side panel if checked=True then it will be activated and the corresponding action will be triggered. if floating=True then the dock widget can be detached from the toolbar and floated as an independent window.

  • Ownership of the widget is transferred to the toolbar.

  • Ownership of the action is transferred to the toolbar.

Rise: Exception when action is None.

addSeparator()

Adds a separator to the end of the toolbar.

addWidget(widget)

Adds the given widget to the toolbar as the toolbar’s last item. The toolbar takes ownership of widget. Returns the action associated to the widget. Rise an exception when widget is None.

createPanel(name, style=None)

Create a widget with the preferred width.

Parameters
  • name – (str) The panel name

  • style – (str) The panel style

getCurrentAction()

Returns the current active action

getIconSize()

Return the maximum size an icon can have

getPanelMaxWidth()

Returns the side panel maximum width

hasVisiblePanel()

Return True if has any panel visible

setPanelMaxSize(width)

Sets the side panel maximum width

setPanelMinSize(width)

Sets the side panel minimum width

setToolButtonStyle(toolButtonStyle)

Set the button style for this MultiStateAction

Parameters

toolButtonStyle – (Qt.ToolButtonStyle) The style for all buttons

OnOffAction

class datavis.widgets.OnOffAction(parent=None, **kwargs)

Subclass of MultiStateAction that provide just to states: on/off.

__init__(parent=None, **kwargs)

Constructs an OnOffAction instance.

Parameters

parent – The parent object

Keyword Args

toolTipOn: (str) The tooltip for On state toolTipOff: (str) The tooltip for Off state

MultiStateAction

class datavis.widgets.MultiStateAction(parent=None, **kwargs)

Action handling multiple internal states.

Each state is a tuple containing (value, icon, tooltip).

__init__(parent=None, **kwargs)

Constructor for MultiStateAction objects.

Parameters

parent – (QObject) Specifies the parent object to which this MultiStateAction will belong.

Keyword Arguments
  • states – (list of (value, icon, tooltip)) All possible states for the MultiStateAction.

  • current – (int) The initial state index in states list.

add(state, icon, tooltip='')

Add a new state to the internal states list.

Parameters
  • state – The state

  • icon – (QIcon) Icon for the specified state

  • tooltip – (str) The tooltip

get()

Get the currently active state.

next()

Move the active state to the next one.

previous()

Move the active state to the previous one.

set(state)

Change the current active state. Raise an Exception if the specified state is invalid.

Parameters

state – The state.

TriggerAction

class datavis.widgets.TriggerAction(parent, actionName=None, text='', faIconName=None, faIconColor=None, icon=None, checkable=False, tooltip=None, slot=None, shortCut=None, userData=None, **kwargs)

The TriggerAction class offers an initialization of configuration params not provided by Qt.

__init__(parent, actionName=None, text='', faIconName=None, faIconColor=None, icon=None, checkable=False, tooltip=None, slot=None, shortCut=None, userData=None, **kwargs)

Creates a TriggerAction with the given name, text and icon. If slot is not None then the signal QAction.triggered is connected to it.

Parameters
  • actionName – (str)The action name

  • text – (str)Action text

  • faIconName – (str)qtawesome icon name

  • icon – (QIcon) used if faIconName=None

  • checkable – (bool)if this action is checkable

  • tooltip – (str) The tooltip text

  • slot – (slot) the slot to connect qtw.QAction.triggered signal

  • shortCut – (QKeySequence) the short cut key

  • userData – User data for specific purposes

getUserData()

Getter for user data

Browser

class datavis.widgets.Browser(**kwargs)

Browser is the base class for browsers that allow users to select paths from a TreeModelView. It will contain a left panel with the TreeModelView, navigation buttons and a completer to facilitate the search. A right panel with ViewPanel (top) and InfoPanel (bottom).

__init__(**kwargs)

Constructs a new Browser object

Keyword Arguments
  • parent – The parent widget

  • The tree model for the view to present. (model) –

  • mode – (int) The TreeView mode. Possible values: TREE_MODE, DIR_MODE

  • navigate – (Boolean) If True, the user can navigate through the directories

  • readOnly (Boolean) – will be disabled

getCurrentIndex()

Return the current index

getModel()

Return the current model

updateViewPanel()

Update the information of the view panel. Implement this method in subclasses for file data visualization

FileModelView

class datavis.widgets.FileModelView(**kwargs)

The FileModelView class is an extension of the TreeModelView class, allowing the file system navigation. FileBrowser is initialized with a QFileSystemModel, having the ‘rootPath’ param as the root path of the model and the ‘selectedPath’ as the current selected path.

__init__(**kwargs)

Constructs an FileBrowser instance

Keyword Arguments
  • parent – The parent widget

  • mode – (int) The TreeView mode. Possible values: TREE_MODE, DIR_MODE

  • navigate – (Boolean) If True, the user can navigate through the directories

  • rootPath – (str) Initial root path

  • selectedPath – (str) The selected path

expandTree(path)

Expand the Tree View to the given path

getRootPath()

Return the root path

getSelectedPath()

Return the current selected path. If selected index is None then return the root path

goHome()

Changes current directory by moving to the home directory.

goUp()

Changes directory by moving one directory up from the current directory.

selectPath(path)

Set the given path as selected. If mode is DIR_MODE then the root path will be the root of the given path.

setRootIndex(index)

Reimplemented from QTreeView

setRootPath(path)

Sets the root path to the given path

Parameters

path – (str) The new root path

FileBrowser

class datavis.widgets.FileBrowser(**kwargs)

The FileBrowser is an extension of Browser class for file navigation

__init__(**kwargs)

Creates a FileBrowser instance

Keyword Arguments
  • The tree model for the view to present. (model) –

  • mode – (int) The TreeView mode. Possible values: TREE_MODE, DIR_MODE

  • navigate – (Boolean) If True, the user can navigate through the directories