Widget#
Custom Widget#
Custom widget.
This module provides customuized widgets.
- class Button(parent=None, text='', toggle=False)[source]#
Bases:
QPushButton
Button widget.
- Parameters:
parent (QWidget, optional) -- parent.
text (str, optional) -- text.
toggle (bool, optional) -- toggle button ?
- class Check(parent=None, text='')[source]#
Bases:
QCheckBox
Check widget.
- Parameters:
parent (QWidget, optional) -- parent.
text (str, optional) -- text.
- class ColorLabel(parent=None, color='', bold=False)[source]#
Bases:
Panel
Color label widget.
- Parameters:
parent (QWidget, optional) -- parent.
color (str, optional) -- color/colormap name.
bold (bool, optional) -- bold font ?
- class ColorSelector(parent=None, current='', color_type='color')[source]#
Bases:
QComboBox
Color selector widget.
- Parameters:
parent (QWidget, optional) -- parent.
current (str, optional) -- default color.
color_type (str, optional) -- color/colormap/color_both
Notes
connect currentTextChanged.
- class Combo(parent=None, item=[], init=None)[source]#
Bases:
QComboBox
Combo widget.
- Parameters:
parent (QWidget, optional) -- parent.
item (list, optional) -- list of items, [str].
init (str, optional) -- initial value.
- class DSpin(parent=None, min=0.0, max=1.0, step=0.1)[source]#
Bases:
QDoubleSpinBox
Spin widget.
- Parameters:
parent (QWidget, optional) -- parent.
min (float, optional) -- minimum value.
max (float, optioanl) -- maximum value.
step (float, optional) -- step value.
- class Editor(parent=None, text='', validator=None, color='black', size=10, dpi=120)[source]#
Bases:
Panel
Math equation label widget.
- Parameters:
parent (QWidget, optional) -- parent.
text (str, optional) -- text.
validator (tuple, optional) -- (validator_type, option).
color (str, optioanl) -- color name.
size (int, optional) -- font size.
dpi (int, optional) -- DPI.
Note
- following validators can be used.
int: (min, max).
float: (min, max, digit).
sympy_float: (digit).
sympy: (variable list).
ilist: (shape).
list: (shape, variable list, digit).
site: (use variable?).
bond: (use variable?).
site_bond: (use variable?).
vector_site_bond: (use variable?).
orbital_site_bond: (use variable?).
- class HBar(parent=None)[source]#
Bases:
QFrame
Horizontal bar item.
- Parameters:
parent (QWidget, optional) -- parent.
- class Label(parent=None, text='', bold=False, color='black', size=10, math=False, dpi=120)[source]#
Bases:
QLabel
Label widget.
- Parameters:
parent (QWidget, optional) -- parent.
text (str, optional) -- text.
bold (bool, optional) -- bold font ?
color (str, optional) -- font color.
size (int, optional) -- font size.
math (bool, optional) -- for math ?
dpi (int, optional) -- DPI for math.
Note
in math mode, text is given in LaTeX code without $.
- class Layout(parent=None)[source]#
Bases:
QGridLayout
Layout widget.
- Parameters:
parent (QWidget, optional) -- parent.
- class LineEdit(parent=None, text='', validator=None)[source]#
Bases:
QLineEdit
Line editor.
- Parameters:
parent (QWidget, optional) -- parent.
text (str, optional) -- text.
validator (tuple, optional) -- (validator_type, option).
- set_validator(validator)[source]#
Set validator.
- Parameters:
validator (tuple) -- (validator_type, option).
- property read_only#
Read only ?
- Returns:
(bool) -- read only ?
- property validator#
Validator type.
- Returns:
(str) -- validator type.
- class Panel(parent=None)[source]#
Bases:
QWidget
Panel widget.
- Parameters:
parent (QWidget, optional) -- parent.
Validator#
Validator type.
- type: option ["*": no limit, digit only for no variable list=None(no check), [""](no variable)]
int: (min, max)
float: (min, max, digit)
sympy_float: (digit)
sympy: (variable list)
ilist: (shape)
list: (shape, variable list, digit)
site: (use variable?)
bond: (use variable?)
site_bond: (use variable?)
vector_site_bond: (use variable?)
orbital_site_bond: (use variable?)
- validator_bond(s, use_var=False)[source]#
Validator for bond.
- Parameters:
s (str) -- bond string.
use_var (bool, optional) -- use [x,y,z] for site/bond ?
- Returns:
(str) -- input s if it is valid, otherwise None.
Note
bond sytles, start:vector, tail;head, vector@center, are accepted.
- validator_float(text, opt)[source]#
Validator for float.
- Parameters:
text (str) -- int string.
opt (tuple, optional) -- option, (min, max, digit).
- Returns:
(str) -- formatted string if it is valid, otherwise None.
- validator_ilist(s, opt)[source]#
Validator for int list.
- Parameters:
s (str) -- int list string.
opt (tuple, optional) -- option, shape, (), (n,), (n,m), ...
- Returns:
(str) -- formatted string if it is valid, otherwise None.
- validator_int(text, opt)[source]#
Validator for int.
- Parameters:
text (str) -- int string.
opt (tuple, optional) -- option, (min, max).
- Returns:
(str) -- formatted string if it is valid, otherwise None.
- validator_list(s, opt)[source]#
Validator for sympy list.
- Parameters:
s (str) -- sympy list string.
opt (tuple, optional) -- option, (shape, var, digit).
- Returns:
(str) -- formatted string if it is valid, otherwise None.
- validator_orbital_site_bond(s, use_var=False)[source]#
Validator for orbital on site or bond.
- Parameters:
s (str) -- orbital on site or bond string.
use_var (bool, optional) -- use [x,y,z] for site/bond ?
- Returns:
(str) -- input s if it is valid, otherwise None.
Note
orbital can contain x, y, z, r.
bond sytles, start:vector, tail;head, vector@center, are accepted.
- validator_site(s, use_var=False)[source]#
Validator for site.
- Parameters:
s (str) -- site string, [x,y,z].
use_var (bool, optional) -- use [x,y,z] for site/bond ?
- Returns:
(str) -- input s if it is valid, otherwise None.
- validator_site_bond(s, use_var=False)[source]#
Validator for site or bond.
- Parameters:
s (str) -- site or bond string.
use_var (bool, optional) -- use [x,y,z] for site/bond ?
- Returns:
(str) -- input s if it is valid, otherwise None.
Note
bond sytles, start:vector, tail;head, vector@center, are accepted.
- validator_sympy(text, opt)[source]#
Validator for sympy.
- Parameters:
text (str) -- sympy string.
opt (list, optional) -- option, var.
- Returns:
(str) -- LaTeX string if it is valid, otherwise None.
- validator_sympy_float(text, opt)[source]#
Validator for sympy.
- Parameters:
text (str) -- sympy string.
opt (int, optional) -- option, digit.
- Returns:
(str) -- formatted string if it is valid, otherwise None.
- validator_vector_site_bond(s, use_var=False)[source]#
Validator for vector on site or bond.
- Parameters:
s (str) -- vector on site or bond string.
use_var (bool, optional) -- use [x,y,z] for site/bond ?
- Returns:
(str) -- input s if it is valid, otherwise None.
Note
bond sytles, start:vector, tail;head, vector@center, are accepted.
Message Box#
MessageBox dialog.
This module provides message box dialog.
Table View#
TableView widget.
This module provides table view widget.
- class TableView(parent=None, data=[['']], header=None, vertical=False, color='black', size=12, dpi=120)[source]#
Bases:
QTableWidget
Table view (math).
- Parameters:
parent (QWidget, optional) -- parent.
data (list, optional) -- table data in LaTeX code without "$".
header (list, optional) -- header string.
vertical (bool, optional) -- show vertical number header ?
color (str, optional) -- color name.
size (int, optional) -- font size.
dpi (int, optional) -- DPI.
Data View and Model#
Tab of GroupView.
This module provides a set of group view classes in tab format.
- class TabGroupView(models, title='Data', parent=None)[source]#
Bases:
QDialog
Data view group.
- Parameters:
models (dict) -- set of models, {object_type: GroupModel}.
title (str, optional) -- window title.
parent (QWidget, optional) -- parent.
View panel for GroupModel.
This module provides a view class to show object data. By clicking right button of mouse, the context menu appears.
- class GroupView(model, parent=None)[source]#
Bases:
QTreeView
Group view.
- Parameters:
model (GroupModel) -- group model.
parent (QWidget, optional) -- parent.
Context menu.
Two-layer tree model for managing objects.
This module provides a class to manage objects to draw. The objects are grouped by the first column, "name". All the objects in the same group can be modified together. When there are more than two objects in the same group, a child tree appears and the parent tree is the same as the first row of the child tree.
The raw data is maintained by dict, and the index model is just to keep the relation between parent and child, which is necessary to use other Qt functionalities.
- class GroupModel(name, column_info, parent=None)[source]#
Bases:
QStandardItemModel
Group data model (2 layer parent-child tree model).
- Parameters:
name (str) -- model name.
column_info (list) -- {header: (type,option,default)} for each column.
parent (QWidget, optional) -- parent.
- action_copy_row(indexes)[source]#
Slot for copy row action.
- Parameters:
indexes (list) -- list of index.
- action_insert_row(indexes)[source]#
Slot for insert row action.
- Parameters:
indexes (list) -- list of index.
- Returns:
(QModelIndex) -- parent index of inserted row.
- action_remove_row(indexes)[source]#
Slot for remove row action.
- Parameters:
indexes (list) -- list of index.
- append_row(row_data=None, role=None, index=<PySide6.QtCore.QModelIndex(-1, -1, 0x0, QObject(0x0))>, copy_row=False)[source]#
Append row.
- Parameters:
row_data (list, optional) -- row data.
role (int, optional) -- role.
index (QModelIndex, optional) -- index.
copy_row (bool, optional) -- copy from current index ?
- block_update_widget(flag)[source]#
Block update widget.
- Parameters:
flag (bool) -- block update ?
Note
in order to avoid unnecessary update of widget, otherwise it becomes very slow.
- debug_data_changed(topLeft, bottomRight, roles=[])[source]#
Debug for dataChanged signal.
- Parameters:
topLeft (QModelIndex) -- top left index.
bottomRight (QModelIndex) -- bottom right index.
roles (list, optional) -- list of roles.
- debug_updata_data(name, row_data, role)[source]#
Debug for updateData signal.
- Parameters:
name (str) -- group name.
row_data (list) -- row data.
role (int) -- role.
- emit_update_data(name, row_data, role, index)[source]#
Emit update data.
- Parameters:
name (str) -- group name.
row_data (list) -- row_data.
role (int) -- role.
index (QModelIndex) -- index.
- find_item(text, column=0, child=True)[source]#
Find item.
- Parameters:
text (str) -- str to find.
column (int, optional) -- column.
child (bool, optional) -- find also for child ?
- Returns:
(list) -- found items.
- get_role_str(role)[source]#
Get role string.
- Parameters:
role (int) -- role.
- Returns:
(str) -- role string.
- get_row_data(index, column=None)[source]#
Get row data.
- Parameters:
index (QModelIndex) -- index.
column (int, optional) -- column.
- Returns:
(list) -- row data.
Note
bool string is replaced by bool.
- is_parent(index)[source]#
Is parent index ?
- Parameters:
index (QModelIndex) -- index.
- Returns:
(bool) -- parent index ?
- move_row(index, value)[source]#
Move row.
- Parameters:
index (QModelIndex) -- index.
value (QVariant) -- value.
- remove_row(index, role=None)[source]#
Remove row.
- Parameters:
index (QModelIndex) -- index.
role (int, optional) -- role.
- setData(index, value, role=ItemDataRole.EditRole)[source]#
Set data (override).
- Parameters:
index (QModelIndex) -- index.
value (QVariant) -- value to set.
role (int, optional) -- role.
- Returns:
(bool) -- success to set data ?
- set_check(index, column, data)[source]#
Set check state.
- Parameters:
index (QModelIndex) -- index.
column (int) -- column.
data (QCheckState) -- check state.
- set_check_state(item, row_data)[source]#
Set check state of row.
- Parameters:
item (QItemModel) -- item of row(s).
row_data (list) -- row data, [str].
- set_row_data(index, column, data)[source]#
Set row data.
- Parameters:
index (QModelIndex) -- index.
column (int) -- column.
data (str) -- data.
- show_index(index)[source]#
Get raw index.
- Parameters:
index (QModelIndex) -- index.
- Returns:
(str) -- raw index, P/C(row,column).
- tolist()[source]#
Convert to list.
- Parameters:
raw (bool, optional) -- raw data ?
- Returns:
(list) -- list data.
- tolist_index(topLeft, bottomRight)[source]#
Row data for given index.
- Parameters:
topLeft (QModelIndex) -- index at top left.
bottomRight (QModelIndex) -- index at buttom right.
- Returns:
(list) -- row data.
- update_check_state(topLeft, bottomRight, roles=[])[source]#
Update check state data.
- Parameters:
topLeft (QModelIndex) -- top left index.
bottomRight (QModelIndex) -- bottom right index.
roles (list, optional) -- list of roles.
Note
set check state (bool) in column+1.
- property group_name#
Group name.
- Returns:
(str) -- group name.
- property header#
Header label.
- Returns:
(list) -- header label.
Delegate for GroupModel and GroupView.
This module provides delegate for color selector, combo, and editor.
- class ColorDelegate(parent)[source]#
Bases:
Delegate
Create delegate for ColorSelector.
- Parameters:
parent (QWidget) -- parent.
- class ComboDelegate(parent)[source]#
Bases:
Delegate
Create delegate for Combo.
- Parameters:
parent (QWidget) -- parent.
- class Delegate(parent)[source]#
Bases:
QStyledItemDelegate
Base delegate.
- Parameters:
parent (QWidget) -- parent.
- paint(painter, option, index)[source]#
Paint cell.
- Parameters:
painter (QPainter) -- painter.
option (QStyleOptionViewItem)
index (QModelIndex) -- index.
- setEditorData(editor, index)[source]#
Set editor data.
- Parameters:
editor (QWidget) -- editor.
index (QModelIndex) -- index.