UI.widgets module

Module to define common graphics widget

  • SimpleStatus: Status with simple format and functionality

  • Status: Label with status (for equipment, stream)

  • Entrada_con_unidades: Composite widget for unit values for input/view

  • Tabla: Custom tablewidget tablewidget with added functionality

  • ClickableLabel: Label with custom clicked signal

  • ColorSelector: Composite widget for colour definition

  • DragButton: Button with drag & drop support

  • PathConfig: Custom widget for file path show and configure

  • LineConfig: Custom QGroupbox with all matplotlib Line configuration

  • GridConfig: Extended version of LineConfig for grid specific line

  • CustomCombo: General custom QComboBox

  • LineStyleCombo: Custom QComboBox for select matplotlib line styles

  • PFDLineCombo: Custom QComboBox for select PFD line styles for stream

  • MarkerCombo: Custom QComboBox for select matplotlib line marker

  • NumericFactor: Numeric format configuration dialog

  • InputFont: Custom widget to edit a text input with font and color support

  • Table_Graphics: Custom widget to implement a popup in PFD

  • func:

    mathTex2QPixmap: Convert a latex text to a QPixmap

  • QLabelMath: Customized QLabel to show a pixmap from a latex code

  • func:

    createAction

  • func:

    okToContinue: Function to ask user if any unsaved change

UI.widgets.translate(context: str, sourceText: str, disambiguation: str = None, n: int = -1) str
class UI.widgets.SimpleStatus[source]

Bases: QLabel

QLabel to show status info

Methods

setState(entity)

Change the state

setState(entity)[source]

Change the state

class UI.widgets.Status(state=0, text='', parent=None)[source]

Bases: QLabel

Widget with status of dialog, equipment, stream, project, …

Methods

restaurar()

Restore old state

setState(state[, text])

Change the state

status = ((0, 'Underspecified', 'yellow'), (1, 'Solved', 'green'), (2, 'Ignored', 'Light gray'), (3, 'Warning', 'green'), (4, 'Calculating...', 'Cyan'), (5, 'Error', 'red'))
__init__(state=0, text='', parent=None)[source]
state:

0 - Not solved 1 - OK 2 - Ignore 3 - Warning (Recommend: Use text parameter to explain) 4 - Calculating 5 - Error

setState(state, text='')[source]

Change the state

restaurar()[source]

Restore old state

class UI.widgets.Entrada_con_unidades(unidad, UIconfig=None, retornar=True, readOnly=False, boton=True, texto=True, textounidad='', title='', value=None, start=0, max=inf, min=0, decimales=4, tolerancia=4, parent=None, width=85, resaltado=False, spinbox=False, suffix='', step=0.01, colorReadOnly=None, colorResaltado=None, frame=True, showNull=False)[source]

Bases: QWidget

Customized widget with unit functionality

Methods

clear()

Clear value

enterEvent(event)

When mouse enter in widget show the unidades and clear button, and add margin to let space to clear button

entrada_editingFinished()

Change the value at finish of edit

keyPressEvent(e)

Manage the key press to emulate a QSpinbox

leaveEvent(event)

When mouse leave the widget undo the enterEvent actions

setFrame(frame)

Set frame of widget

setNotReadOnly(editable)

Inverse readonly slot

setReadOnly(readOnly)

Set read only state for widget

setResaltado(boolean)

Set resalted background color for input widget

setRetornar(retornar)

Update value of widget from unit values list dialog

setToolTip()

Define the tooltip with the values in confguration

setValue(value)

Set value of widget

unidades_clicked()

Show the unit converter dialog

valueChanged

valueChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(unidad, UIconfig=None, retornar=True, readOnly=False, boton=True, texto=True, textounidad='', title='', value=None, start=0, max=inf, min=0, decimales=4, tolerancia=4, parent=None, width=85, resaltado=False, spinbox=False, suffix='', step=0.01, colorReadOnly=None, colorResaltado=None, frame=True, showNull=False)[source]
Units:

unidad: The unit (lib/unidades class) to use, mandatory UIconfig: Magnitud necessary if the main unit have several meaning title: Update unit title property retornar: Boolean to let or avoid the conversion window update

the value of widget

value: Inicial value of widget max: Maximum value for widget min: Minimum value for widget decimales: Decimal number count to show of value tolerancia: Value of exponent over than to use exponential notation

UI:

readOnly: Boolean, set widget readOnly property frame: Boolean, show the frame of widget or not width: Width of value widget boton: Boolean, show or not the button for unit conversion dialog texto: Boolean, show the unit text at right of value textounidad: Alternate text to show as unit text suffix: Text added to value in value representation showNull: Boolean, show value if it’s 0 resaltado: Boolean, use base color in widget colorResaltado: Color to use as base color if value colorReadOnly: Color to use is the widget is readOnly

Spinbox functionality:

spinbox: boolean to specified a QSpinbox use, with mouse response start: initial value for spinbox mouse interaction step: value of step at mouse spingox interaction

unidades_clicked()[source]

Show the unit converter dialog

entrada_editingFinished()[source]

Change the value at finish of edit

clear()[source]

Clear value

setResaltado(boolean)[source]

Set resalted background color for input widget

setReadOnly(readOnly)[source]

Set read only state for widget

setNotReadOnly(editable)[source]

Inverse readonly slot

setRetornar(retornar)[source]

Update value of widget from unit values list dialog

setValue(value)[source]

Set value of widget

setFrame(frame)[source]

Set frame of widget

setToolTip()[source]

Define the tooltip with the values in confguration

keyPressEvent(e)[source]

Manage the key press to emulate a QSpinbox

enterEvent(event)[source]

When mouse enter in widget show the unidades and clear button, and add margin to let space to clear button

leaveEvent(event)[source]

When mouse leave the widget undo the enterEvent actions

class UI.widgets.Tabla(columnas=0, filas=0, stretch=True, dinamica=False, readOnly=False, columnReadOnly=None, horizontalHeader=None, verticalHeader=True, verticalHeaderLabels=None, verticalHeaderModel='', verticalOffset=0, orientacion=<AlignmentFlag.AlignRight: 2>, delegate=<class 'UI.delegate.CellEditor'>, delegateforRow=None, parent=None)[source]

Bases: QTableWidget

QTableWidget with custom functionality

Methods

addRow([data, index])

Add row to widget data: Array with data to fill new row index: Index to add row, default add row at endo of table

clear([size])

Clear table, remove all data and optionally remove all row

getColumn(column)

Get column data as array

getData()

Get all table data as array

getRow(row)

Get row data as array

getValue(row, column)

Get value from cell in row and column

leaveEvent(event)

Emit editingFinished when focus leave widget

setColumn(column, data, **fmt)

Set data for a complete column

setColumnReadOnly(column, boolean)

Set readonly estate per column

setConnected()

The dynamic state can be defined at start or call this procedure

setData(matriz)

Set table data

setVHeader(row)

Set vertical header text

setValue(row, column, value, **fmt)

Set value for cell in row and column with text formating

tabla_cellChanged(i, j)

When edit a cell, check status to add new row

editingFinished

rowFinished

editingFinished

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

rowFinished

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(columnas=0, filas=0, stretch=True, dinamica=False, readOnly=False, columnReadOnly=None, horizontalHeader=None, verticalHeader=True, verticalHeaderLabels=None, verticalHeaderModel='', verticalOffset=0, orientacion=<AlignmentFlag.AlignRight: 2>, delegate=<class 'UI.delegate.CellEditor'>, delegateforRow=None, parent=None)[source]

columnas: Column count of widget filas: Row count, this value is initial and can be changed stretch: Boolean, stretch the last column to fill all space available dinamica: Boolean, let user fill the data adding new row when last

are filled

readOnly: Boolean, set the readOnly state of widget columnReadOnly: Array with boolean for column readOnly state, used when

the readOnly state is different for each column

horizontalHeader: Array with text for top header,

Null don’t show the top header

verticalHeader: Boolean, to show or hide the right header verticalHeaderLabels: Array with text for right header verticalHeaderModel: If the table is dinamica and the right header is

show, this are the text model to generate new vertical header label

verticalOffset: Index, row don’t included in fill data, used for show

info, widget…

orientation: Horizontal text alignment general for cell in tables,

default is right as normal for numbers

delegate: QItemDelegate subclass to configure cell editor

default CellEditor with float appropiate functionality

delegateforRow: delegate with specific values for row

setConnected()[source]

The dynamic state can be defined at start or call this procedure

addRow(data=None, index=None)[source]

Add row to widget data: Array with data to fill new row index: Index to add row, default add row at endo of table

setVHeader(row)[source]

Set vertical header text

tabla_cellChanged(i, j)[source]

When edit a cell, check status to add new row

getValue(row, column)[source]

Get value from cell in row and column

setValue(row, column, value, **fmt)[source]

Set value for cell in row and column with text formating

setColumn(column, data, **fmt)[source]

Set data for a complete column

getColumn(column)[source]

Get column data as array

getRow(row)[source]

Get row data as array

getData()[source]

Get all table data as array

setData(matriz)[source]

Set table data

clear(size=True)[source]

Clear table, remove all data and optionally remove all row

setColumnReadOnly(column, boolean)[source]

Set readonly estate per column

leaveEvent(event)[source]

Emit editingFinished when focus leave widget

class UI.widgets.ClickableLabel[source]

Bases: QLabel

Custom QLabel with clicked functionality

Methods

mousePressEvent(event)

Use mouse press event to simulate clicked signal

clicked

clicked

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

mousePressEvent(event)[source]

Use mouse press event to simulate clicked signal

class UI.widgets.ColorSelector(color='#ffffff', alpha=255, isAlpha=False, parent=None)[source]

Bases: QWidget

Color selector widget

Methods

ColorButtonClicked()

Show the QColorDialog to let user choose new color

rgbChanged()

Let user define the color manually

setColor(color[, alpha])

Set new color value and update text and button color

valueChanged

valueChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(color='#ffffff', alpha=255, isAlpha=False, parent=None)[source]
setColor(color, alpha=255)[source]

Set new color value and update text and button color

ColorButtonClicked()[source]

Show the QColorDialog to let user choose new color

rgbChanged()[source]

Let user define the color manually

class UI.widgets.DragButton(parent=None)[source]

Bases: QToolButton

Class to define a special button with drag/drop supoort

Methods

mouseMoveEvent(event)

Do the drag & drop actions

mousePressEvent(event)

Register the start position to do the drag action and enable the normal clicking action

__init__(parent=None)[source]
mousePressEvent(event)[source]

Register the start position to do the drag action and enable the normal clicking action

mouseMoveEvent(event)[source]

Do the drag & drop actions

class UI.widgets.PathConfig(title='', path='', patron='', msg='', folder=False, save=False, parent=None)[source]

Bases: QWidget

Custom widget for a file path show and configure functionality

Methods

pathEdited(path)

Emit valueChanged signals when path is changed

select()

Open the QFileDialog to select the file path

setText

text

valueChanged

valueChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(title='', path='', patron='', msg='', folder=False, save=False, parent=None)[source]

title: Optional text an right of widget path: Inicial value for file path patron: File format to filter in file search dialog msg: Title of dialog file

text()[source]
setText(text)[source]
select()[source]

Open the QFileDialog to select the file path

pathEdited(path)[source]

Emit valueChanged signals when path is changed

class UI.widgets.LineConfig(confSection, title, parent=None)[source]

Bases: QGroupBox

Custom QGroupbox with all matplotlib Line configuration

Methods

changeMarker(index)

Update visibility of marker properties widget when any marker is selected

setConfig(config[, section])

Set widget values from config

value(config[, section])

Update ConfigParser instance with the config

__init__(confSection, title, parent=None)[source]

confSection: Name key to identify the line title: Title to use in QGroupbox

changeMarker(index)[source]

Update visibility of marker properties widget when any marker is selected

setConfig(config, section='MEOS')[source]

Set widget values from config

value(config, section='MEOS')[source]

Update ConfigParser instance with the config

class UI.widgets.GridConfig(confSection, title, parent=None)[source]

Bases: LineConfig

Extended version of LineConfig for grid specific line

Methods

setConfig(config, section)

Set widget values from config

value(config, section)

Update ConfigParser instance with the config

WHICH = ['both', 'major', 'minor']
AXIS = ['both', 'x', 'y']
__init__(confSection, title, parent=None)[source]

confSection: Name key to identify the line title: Title to use in QGroupbox

setConfig(config, section)[source]

Set widget values from config

value(config, section)[source]

Update ConfigParser instance with the config

class UI.widgets.CustomCombo(parent=None)[source]

Bases: QComboBox

General custom QComboBox

Methods

currentValue()

Convert index in value from keymap

emit(ind)

Emit signal change integer for keymap value

setCurrentValue(value)

Overload QComboBox setCurrentValue to let text input from keymap

valueChanged

valueChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(parent=None)[source]
setCurrentValue(value)[source]

Overload QComboBox setCurrentValue to let text input from keymap

currentValue()[source]

Convert index in value from keymap

emit(ind)[source]

Emit signal change integer for keymap value

class UI.widgets.LineStyleCombo(parent=None)[source]

Bases: CustomCombo

Custom QComboBox for select matplotlib line styles

key = ['None', '-', '--', ':', '-.']
image = {'-': 'images/button/solid_line.png', '--': 'images/button/dash_line.png', '-.': 'images/button/dash_dot_line.png', ':': 'images/button/dot_line.png', 'None': ''}
_populate()[source]
class UI.widgets.PFDLineCombo(parent=None)[source]

Bases: LineStyleCombo

Custom QComboBox for select PFD line styles for stream

Methods

valueChanged

key = [PenStyle.SolidLine, PenStyle.DashLine, PenStyle.DotLine, PenStyle.DashDotLine, PenStyle.DashDotDotLine]
image = {PenStyle.DashDotDotLine: 'images/button/dash_dot_dot_line.png', PenStyle.DashDotLine: 'images/button/dash_dot_line.png', PenStyle.DashLine: 'images/button/dash_line.png', PenStyle.DotLine: 'images/button/dot_line.png', PenStyle.SolidLine: 'images/button/solid_line.png'}
valueChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

class UI.widgets.MarkerCombo(parent=None)[source]

Bases: CustomCombo

Custom QComboBox for select matplotlib line marker

key = ['None', '.', ',', 'o', 'v', '^', '<', '>', '1', '2', '3', '4', '8', 's', 'p', '*', 'h', 'H', '+', 'x', 'D', 'd', '|', '_']
text = {'*': 'star', '+': 'plus', ',': 'pixel', '.': 'point', '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', '<': 'triangle_left', '>': 'triangle_right', 'D': 'diamond', 'H': 'hexagon2', 'None': '', '^': 'triangle_up', '_': 'hline', 'd': 'thin_diamond', 'h': 'hexagon1', 'o': 'circle', 'p': 'pentagon', 's': 'square', 'v': 'triangle_down', 'x': 'x', '|': 'vline'}
_populate()[source]
class UI.widgets.NumericFactor(config, unit=None, order=0, parent=None)[source]

Bases: QDialog

Numeric format configuration dialog

Methods

ExpToggled(boolean)

Exponential checkbox toggled

args()

Return a dict with the selected numeric representation parameters

updateMuestra()

Update numeric sample

__init__(config, unit=None, order=0, parent=None)[source]
ExpToggled(boolean)[source]

Exponential checkbox toggled

updateMuestra()[source]

Update numeric sample

args()[source]

Return a dict with the selected numeric representation parameters

class UI.widgets.InputFont(text='', font=None, color='#000000', parent=None)[source]

Bases: QWidget

Custom widget to edit a text input with font and color support

Methods

colorButtonClicked()

Show QColorDialog to change the color

fontButtonClicked()

Show QFontDialog to choose the font

setColor(color)

Set color for widget

setFont(font)

Set font for widget

setRGB(rgb)

Wrap method to set color with a #rrggbb code

setText(txt)

Set text for QLineEdit

colorChanged

fontChanged

textChanged

textChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

fontChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

colorChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__(text='', font=None, color='#000000', parent=None)[source]

text: Initial txt for widget font: QFont instance to initialize widget color: Inicial color to widget, in code #rrggbb

setText(txt)[source]

Set text for QLineEdit

setRGB(rgb)[source]

Wrap method to set color with a #rrggbb code

setColor(color)[source]

Set color for widget

setFont(font)[source]

Set font for widget

colorButtonClicked()[source]

Show QColorDialog to change the color

fontButtonClicked()[source]

Show QFontDialog to choose the font

class UI.widgets.Table_Graphics(entity=None, idx=None, preferences=None, parent=None)[source]

Bases: QWidget

Custom widget to implement as popup in PFD when mouse over stream and equipment graphic item, to show the status of entity and the properties desired if availables

Methods

clear()

Clear content of widget

populate(entity, idx, preferences)

Populate the widget with the new values

__init__(entity=None, idx=None, preferences=None, parent=None)[source]
clear()[source]

Clear content of widget

populate(entity, idx, preferences)[source]

Populate the widget with the new values

UI.widgets.createAction(text, **kw)[source]

Create a QAction and a QToolButton if its requested

Parameters:
textstr

Text to define action

buttonboolean

Return too a QToolButton with same properties

iconstr

Local path of icon in pychemqt images folder

slotobj

Function to use as slot when action is triggered

shortcutQtGui.QKeySequence

Shortcut keyboard to associate with action

tipstr

Text to use as tooltip

checkableboolean

Set the created action checkable

parentQtCore.QObject

Define object parent of created action and button

UI.widgets.okToContinue(parent, dirty, func, *parameters)[source]

Function to ask user if any unsaved change

Parameters:
parentQtWidgets.QWidget

Parent widget to dialog

dirty: boolean

Indicates if there are unsaved changes

func: object

function to run if user want to save changes

parameters: dict

parameter of func

UI.widgets.mathTex2QPixmap(mathTex, fs)[source]

Convert a latex text to a QPixmap to display in any qt widget. Code snippet from https://stackoverflow.com/questions/32035251

Parameters:
mathTexstr

Latex text of expression to show

fsint

Font size of text to show

Returns:
qpixmapQtGui.QPixmap

QPixmap ready to show in any other qt widget

class UI.widgets.QLabelMath(tex, *args, fs=12, **kw)[source]

Bases: QLabel

Customized QLabel to show a pixmap with a mathematical formulae

Methods

setTex(tex)

Set the image to show from a latex text source

__init__(tex, *args, fs=12, **kw)[source]
Parameters:
texstr

Latex code text of mathematical expresion to show

fsint

Font size used in image

setTex(tex)[source]

Set the image to show from a latex text source

UI.widgets.demo()[source]

Show a demo widget with implemented custom widget