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
- class UI.widgets.SimpleStatus[source]¶
Bases:
QLabelQLabel to show status info
Methods
setState(entity)Change the state
- class UI.widgets.Status(state=0, text='', parent=None)[source]¶
Bases:
QLabelWidget with status of dialog, equipment, stream, project, …
Methods
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'))¶
- 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:
QWidgetCustomized 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
Change the value at finish of edit
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
Define the tooltip with the values in confguration
setValue(value)Set value of widget
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
- 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:
QTableWidgetQTableWidget 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
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
- 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
- class UI.widgets.ClickableLabel[source]¶
Bases:
QLabelCustom 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.
- class UI.widgets.ColorSelector(color='#ffffff', alpha=255, isAlpha=False, parent=None)[source]¶
Bases:
QWidgetColor selector widget
Methods
Show the QColorDialog to let user choose new color
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.
- class UI.widgets.DragButton(parent=None)[source]¶
Bases:
QToolButtonClass 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
- class UI.widgets.PathConfig(title='', path='', patron='', msg='', folder=False, save=False, parent=None)[source]¶
Bases:
QWidgetCustom 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.
- class UI.widgets.LineConfig(confSection, title, parent=None)[source]¶
Bases:
QGroupBoxCustom 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
- class UI.widgets.GridConfig(confSection, title, parent=None)[source]¶
Bases:
LineConfigExtended 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']¶
- class UI.widgets.CustomCombo(parent=None)[source]¶
Bases:
QComboBoxGeneral custom QComboBox
Methods
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.
- class UI.widgets.LineStyleCombo(parent=None)[source]¶
Bases:
CustomComboCustom 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': ''}¶
- class UI.widgets.PFDLineCombo(parent=None)[source]¶
Bases:
LineStyleComboCustom 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:
CustomComboCustom 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'}¶
- class UI.widgets.NumericFactor(config, unit=None, order=0, parent=None)[source]¶
Bases:
QDialogNumeric format configuration dialog
Methods
ExpToggled(boolean)Exponential checkbox toggled
args()Return a dict with the selected numeric representation parameters
Update numeric sample
- class UI.widgets.InputFont(text='', font=None, color='#000000', parent=None)[source]¶
Bases:
QWidgetCustom widget to edit a text input with font and color support
Methods
Show QColorDialog to change the color
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.
- class UI.widgets.Table_Graphics(entity=None, idx=None, preferences=None, parent=None)[source]¶
Bases:
QWidgetCustom 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
- 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:
- qpixmap
QtGui.QPixmap QPixmap ready to show in any other qt widget
- qpixmap
- class UI.widgets.QLabelMath(tex, *args, fs=12, **kw)[source]¶
Bases:
QLabelCustomized QLabel to show a pixmap with a mathematical formulae
Methods
setTex(tex)Set the image to show from a latex text source