本文整理汇总了Python中UI.widgets.Tabla.addRow方法的典型用法代码示例。如果您正苦于以下问题:Python Tabla.addRow方法的具体用法?Python Tabla.addRow怎么用?Python Tabla.addRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI.widgets.Tabla
的用法示例。
在下文中一共展示了Tabla.addRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: widgetReacciones
# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import addRow [as 别名]
class widgetReacciones(QtWidgets.QWidget):
"""Widget con la tabla de reacciones y los botones para modificar la lista de reacciones"""
changed = QtCore.pyqtSignal()
reacciones=[]
reaccion=None
activo=None
ajuste=None
def __init__(self, parent=None):
super(widgetReacciones, self).__init__(parent)
self.indices, self.nombres, M=getComponents()
gridLayout = QtWidgets.QGridLayout(self)
self.TablaReacciones=Tabla(5, horizontalHeader=[QtWidgets.QApplication.translate("pychemqt", "Reaction"), "ΔHr, %s" %unidades.MolarEnthalpy(None).text(), QtWidgets.QApplication.translate("pychemqt", "Type"), QtWidgets.QApplication.translate("pychemqt", "Phase"), QtWidgets.QApplication.translate("pychemqt", "Description")], dinamica=False, verticalHeader=True, orientacion=QtCore.Qt.AlignLeft)
self.TablaReacciones.setMinimumWidth(500)
self.TablaReacciones.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.TablaReacciones.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
self.TablaReacciones.horizontalHeader().setStretchLastSection(True)
self.TablaReacciones.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.TablaReacciones.itemSelectionChanged.connect(self.actualizarBotones)
gridLayout.addWidget(self.TablaReacciones,1,1,6,4)
self.botonAbrir=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/fileOpen.png")), QtWidgets.QApplication.translate("pychemqt", "Open"))
self.botonAbrir.clicked.connect(self.botonAbrirClicked)
gridLayout.addWidget(self.botonAbrir,1,5)
self.botonGuardar=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/fileSave.png")), QtWidgets.QApplication.translate("pychemqt", "Save"))
self.botonGuardar.clicked.connect(self.botonGuardarClicked)
self.botonGuardar.setSizePolicy(QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed)
self.botonGuardar.setEnabled(False)
gridLayout.addWidget(self.botonGuardar,2,5)
self.botonNew=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/fileNew.png")), QtWidgets.QApplication.translate("pychemqt", "New"))
self.botonNew.clicked.connect(self.botonNewClicked)
gridLayout.addWidget(self.botonNew,3,5)
self.botonEdit=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/editor.png")), QtWidgets.QApplication.translate("pychemqt", "Edit"))
self.botonEdit.setEnabled(False)
self.botonEdit.setCheckable(True)
self.botonEdit.clicked.connect(self.botonEditClicked)
gridLayout.addWidget(self.botonEdit,4,5)
self.botonDelete=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/editDelete.png")), QtWidgets.QApplication.translate("pychemqt", "Delete"))
self.botonDelete.setEnabled(False)
self.botonDelete.clicked.connect(self.botonDeleteClicked)
gridLayout.addWidget(self.botonDelete,5,5)
self.botonClear=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/clear.png")), QtWidgets.QApplication.translate("pychemqt", "Clear"))
self.botonClear.clicked.connect(self.botonClearClicked)
gridLayout.addWidget(self.botonClear,6,5)
gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),10,1)
def actualizarBotones(self, bool=True):
self.botonEdit.setEnabled(bool)
self.botonDelete.setEnabled(bool)
def botonAbrirClicked(self):
fname = str(QtWidgets.QFileDialog.getOpenFileName(self, QtWidgets.QApplication.translate("pychemqt", "Open reaction file"), "./", QtWidgets.QApplication.translate("pychemqt", "reaction file")+" (*.rec);;"+QtWidgets.QApplication.translate("pychemqt", "All files")+" (*.*)")[0])
if fname:
with open(fname, "r") as archivo:
reacciones=pickle.load(archivo)
print(reacciones)
self.reacciones=reacciones
self.botonGuardar.setEnabled(True)
for fila, reaccion in enumerate(reacciones):
self.TablaReacciones.addRow()
self.TablaReacciones.setValue(fila, 0, reaccion.text)
self.TablaReacciones.setValue(fila, 1, "%0.4e" %reaccion.Hr.config(), QtCore.Qt.AlignRight)
self.TablaReacciones.setValue(fila, 2, str(reaccion.tipo+1)+" - "+reaction.Reaction.TEXT_TYPE[reaccion.tipo])
self.TablaReacciones.setValue(fila, 3, reaction.Reaction.TEXT_PHASE[reaccion.fase])
self.TablaReacciones.item(fila, 4).setFlags(QtCore.Qt.ItemIsEditable|QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable)
for i in range(4):
self.TablaReacciones.resizeColumnToContents(i)
self.changed.emit()
def botonGuardarClicked(self):
fname = str(QtWidgets.QFileDialog.getSaveFileName(self, QtWidgets.QApplication.translate("pychemqt", "Save reaction to file"), "./", QtWidgets.QApplication.translate("pychemqt", "reaction file")+" (*.rec)")[0])
if fname:
if fname.split(".")[-1]!="rec":
fname+=".rec"
pickle.dump(self.reacciones, open(fname, "w"))
def botonNewClicked(self):
dialog=UI_reacciones(parent=self)
if dialog.exec_():
pass
def botonEditClicked(self, bool):
if bool:
indice=self.TablaReacciones.currentRow()
reaccion=self.reacciones[indice]
dialogo=UI_reacciones(reaccion, self)
dialogo.exec_()
# self.rellenar(self.reaccion)
# self.activo=indice
else:
self.botonAddClicked(self.activo, False)
self.reacciones[self.activo]=self.reaccion
self.TablaReacciones.setCurrentCell(self.activo, 0)
self.activo=-1
self.changed.emit()
#.........这里部分代码省略.........
示例2: InputTableWidget
# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import addRow [as 别名]
class InputTableWidget(QtWidgets.QWidget):
"""Table data input dialog"""
def __init__(self, columnas, data=None, t=[], property=[],
horizontalHeader=[], title="", DIPPR=False, hasTc=0,
Tc=None, eq=1, unit=[], parent=None):
"""
data: mrray with original data
t: values for x column, generally temperature
property: values for 2...n columns
horizontalHeader: List with column title
DIPPR: boolean to show DIPPR widget
hasTc: boolean to show critical temperature (some DIPPR eq need it)
Tc: value for critical temperature
eq: Value for DIPPR equation
unit: List of unidades classes for column definition
"""
super(InputTableWidget, self).__init__(parent)
self.columnas = columnas
self.title = title
self.unit = unit
gridLayout = QtWidgets.QGridLayout(self)
gridLayout.setContentsMargins(0, 0, 0, 0)
openButton = QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(
os.environ["pychemqt"]+"/images/button/fileOpen.png")), "")
openButton.setToolTip(QtWidgets.QApplication.translate(
"pychemqt", "Load data from a file"))
openButton.clicked.connect(self.open)
gridLayout.addWidget(openButton, 1, 1)
saveButton = QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(
os.environ["pychemqt"]+"/images/button/fileSave.png")), "")
saveButton.setToolTip(QtWidgets.QApplication.translate(
"pychemqt", "Save data to a file"))
saveButton.clicked.connect(self.save)
gridLayout.addWidget(saveButton, 1, 2)
clearButton = QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(
os.environ["pychemqt"]+"/images/button/clear.png")), "")
clearButton.setToolTip(QtWidgets.QApplication.translate(
"pychemqt", "Clear data"))
clearButton.clicked.connect(self.delete)
gridLayout.addWidget(clearButton, 1, 3)
gridLayout.addItem(QtWidgets.QSpacerItem(
0, 0, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Fixed), 1, 4)
self.tabla = Tabla(self.columnas, horizontalHeader=horizontalHeader,
verticalHeader=False, stretch=False)
self.tabla.setConnected()
if unit:
hHeader = []
for unit, title in zip(self.unit, horizontalHeader):
hHeader.append("%s, %s" % (title, unit.text()))
self.tabla.setHorizontalHeaderLabels(hHeader)
self.tabla.horizontalHeader().sectionClicked.connect(self.editUnit)
if data:
self.tabla.setData(data)
self.tabla.addRow()
elif t and property:
self.tabla.setColumn(0, t)
self.tabla.setColumn(1, property)
gridLayout.addWidget(self.tabla, 2, 1, 1, 4)
if DIPPR:
self.eqDIPPR = eqDIPPR(eq)
gridLayout.addWidget(self.eqDIPPR, 3, 1, 1, 4)
self.eqDIPPR.eqDIPPR.valueChanged.connect(self.showTc)
self.labelTc = QtWidgets.QLabel("Tc: ", self)
gridLayout.addWidget(self.labelTc, 4, 1)
self.tc = Entrada_con_unidades(Temperature, value=Tc)
gridLayout.addWidget(self.tc, 4, 2, 1, 3)
self.showTc(1)
def showTc(self, value):
"""Show/hide Tc widget"""
self.labelTc.setVisible(value in (7, 9))
self.tc.setVisible(value in (7, 9))
def open(self):
"""Load data from a test file"""
fname, ext = QtWidgets.QFileDialog.getOpenFileName(
self,
QtWidgets.QApplication.translate("pychemqt", "Open text file"),
"./")
if fname:
try:
# Numpy raise error if use the fname directly and find a
# non-latin1 character, inclusive in comment lines
with open(fname, "rb") as file:
data = loadtxt(file)
self.delete()
self.tabla.setData(data)
except ValueError as er:
# Raise a error msg if the file can load by loadtxt, the user
# can select any type of file and the input error is possible
title = QtWidgets.QApplication.translate(
"pychemqt", "Failed to load file")
msg = fname + "\n" + er.args[0]
QtWidgets.QMessageBox.critical(self, title, msg)
#.........这里部分代码省略.........
示例3: UI_reacciones
# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import addRow [as 别名]
class UI_reacciones(QtWidgets.QDialog):
reaction=reaction.Reaction()
def __init__(self, reaccion=None, parent=None):
super(UI_reacciones, self).__init__(parent)
self.evaluate=Evaluate()
self.evaluate.finished.connect(self.rellenar)
self.indices, self.nombres, M=getComponents()
gridLayout = QtWidgets.QGridLayout(self)
lyt=QtWidgets.QHBoxLayout()
lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Key component")))
self.key=QtWidgets.QComboBox()
for i, nombre in enumerate(self.nombres):
self.key.addItem("%i - %s" %(i+1, nombre))
self.key.currentIndexChanged.connect(partial(self.changeParams, "key"))
lyt.addWidget(self.key)
lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed))
gridLayout.addLayout(lyt,1,1,1,5)
lyt=QtWidgets.QHBoxLayout()
lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Phase")))
self.fase=QtWidgets.QComboBox()
for txt in reaction.Reaction.TEXT_PHASE:
self.fase.addItem(txt)
self.fase.currentIndexChanged.connect(partial(self.changeParams, "fase"))
lyt.addWidget(self.fase)
self.Formula=QtWidgets.QLabel()
self.Formula.setAlignment(QtCore.Qt.AlignCenter)
self.Formula.setSizePolicy(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed)
lyt.addWidget(self.Formula)
gridLayout.addLayout(lyt,2,1,1,5)
lyt=QtWidgets.QVBoxLayout()
title=self.nombres[:]
title.append("")
self.Estequiometria=Tabla(1, verticalHeaderLabels=title, horizontalHeader=[QtWidgets.QApplication.translate("pychemqt", "Coefficients")], filas=len(self.indices))
self.Estequiometria.setFixedHeight(22*len(self.indices)+22+4+22)
lyt.addWidget(self.Estequiometria)
self.Estequiometria.addRow()
brush=QtGui.QBrush(QtGui.QColor("#eaeaea"))
self.Estequiometria.item(len(self.indices), 0).setBackground(brush)
self.Estequiometria.item(len(self.indices), 0).setFlags(QtCore.Qt.NoItemFlags)
self.Estequiometria.cellChanged.connect(self.reaccionCambiada)
lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Expanding))
gridLayout.addLayout(lyt,3,1,1,2)
lyt=QtWidgets.QGridLayout()
lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),1,1)
self.formula=QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "Use name in formula"))
self.formula.toggled.connect(partial(self.changeParams, "formula"))
lyt.addWidget(self.formula,1,2,1,2)
self.customHr=QtWidgets.QCheckBox("ΔHr "+QtWidgets.QApplication.translate("pychemqt", "user specified"))
self.customHr.toggled.connect(self.changeHr)
lyt.addWidget(self.customHr,2,2,1,2)
lyt.addWidget(QtWidgets.QLabel("ΔHr<sup>o</sup>"),3,2)
self.Hr=Entrada_con_unidades(unidades.MolarEnthalpy, readOnly=True)
self.Hr.valueChanged.connect(partial(self.changeParams, "Hr"))
lyt.addWidget(self.Hr,3,3)
lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Expanding))
gridLayout.addLayout(lyt,3,3,1,2)
gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),4,2)
lyt=QtWidgets.QHBoxLayout()
lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Type")))
self.tipo=QtWidgets.QComboBox()
for txt in reaction.Reaction.TEXT_TYPE:
self.tipo.addItem(txt)
self.tipo.currentIndexChanged.connect(partial(self.changeParams, "tipo"))
lyt.addWidget(self.tipo)
lyt.addItem(QtWidgets.QSpacerItem(20,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed))
lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Concentration")))
self.base=QtWidgets.QComboBox()
for txt in reaction.Reaction.TEXT_BASE:
self.base.addItem(txt)
self.base.currentIndexChanged.connect(partial(self.changeParams, "base"))
lyt.addWidget(self.base)
lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed))
gridLayout.addLayout(lyt,5,1,1,5)
self.stacked = QtWidgets.QStackedWidget()
self.tipo.currentIndexChanged.connect(self.stacked.setCurrentIndex)
gridLayout.addWidget(self.stacked,6,1,1,5)
gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),7,1,1,5)
widget=QtWidgets.QWidget()
self.stacked.addWidget(widget)
lyt=QtWidgets.QGridLayout(widget)
lyt.addWidget(QtWidgets.QLabel("<h3>"+QtWidgets.QApplication.translate("pychemqt", "Estequiometric reaction")+"</h3>"),1,1,1,4)
self.Conversion=Tabla(1, verticalHeaderModel="C", filas=3)
self.Conversion.setConnected()
self.Conversion.setFixedWidth(100)
lyt.addWidget(self.Conversion,2,1,3,1)
label=QtWidgets.QLabel()
label.setPixmap(QtGui.QPixmap(os.environ["pychemqt"]+"/images/equation/reaction_conversion.png"))
lyt.addWidget(label,2,2,1,3)
lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Temperature unit")),3,2)
self.unidadesTemperatura=QtWidgets.QComboBox()
for i in unidades.Temperature.__text__:
self.unidadesTemperatura.addItem(i)
#.........这里部分代码省略.........
示例4: UI_equipment
# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import addRow [as 别名]
class UI_equipment(UI_equip):
"""Spreadsheet interaction equipment edition dialog"""
Equipment = Spreadsheet()
def __init__(self, equipment=None, project=None, parent=None):
"""
equipment: Initial equipment instance to model
"""
super().__init__(Spreadsheet, entrada=True, salida=True,
calculo=False, parent=parent)
self.project = project
# Calculate tab
layout = QtWidgets.QGridLayout(self.Entrada)
label = QtWidgets.QApplication.translate(
"pychemqt", "Spreadsheet path")+":"
msg = QtWidgets.QApplication.translate(
"pychemqt", "Select Spreadsheet")
patrones = []
if os.environ["ezodf"]:
patrones.append(QtWidgets.QApplication.translate(
"pychemqt", "Libreoffice spreadsheet files")+" (*.ods)")
if os.environ["xlwt"]:
patrones.append(QtWidgets.QApplication.translate(
"pychemqt", "Microsoft Excel 97/2000/XP/2003 XML")+" (*.xls)")
if os.environ["openpyxl"]:
patrones.append(QtWidgets.QApplication.translate(
"pychemqt", "Microsoft Excel 2007/2010 XML")+" (*.xlsx)")
patron = ";;".join(patrones)
self.filename = PathConfig(label, msg=msg, patron=patron)
self.filename.valueChanged.connect(self.changeSpreadsheet)
layout.addWidget(self.filename, 1, 1)
header = [QtWidgets.QApplication.translate("pychemqt", "Entity"),
QtWidgets.QApplication.translate("pychemqt", "Variable"),
QtWidgets.QApplication.translate("pychemqt", "Unit value"),
QtWidgets.QApplication.translate("pychemqt", "Sheet"),
QtWidgets.QApplication.translate("pychemqt", "Cell")]
self.datamap = Tabla(
5, filas=1, dinamica=True, horizontalHeader=header,
verticalHeader=False, orientacion=QtCore.Qt.AlignLeft,
delegate=None, delegateforRow=TableDelegate, parent=self)
self.datamap.setEnabled(False)
self.datamap.cellChanged.connect(self.cellChanged)
self.datamap.rowFinished.connect(self.addRow)
layout.addWidget(self.datamap, 2, 1)
layout.addItem(QtWidgets.QSpacerItem(
10, 10, QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding), 10, 1)
entitys = []
for stream in list(self.project.streams.keys()):
entitys.append("s%i" % stream)
for equip in list(self.project.items.keys()):
if equip[0] == "e":
entitys.append(equip)
self.datamap.itemDelegateForRow(0).setItemsByIndex(0, entitys)
self.entitys = entitys
if equipment:
self.setEquipment(equipment)
def changeSpreadsheet(self, path):
self.datamap.setEnabled(bool(path))
self.changeParams("filename", str(path))
self.datamap.blockSignals(True)
self.datamap.clear()
self.datamap.blockSignals(False)
spreadsheet = ezodf.opendoc(path)
sheets = [name for name in spreadsheet.sheets.names()]
self.datamap.itemDelegateForRow(0).setItemsByIndex(3, sheets)
def rellenarInput(self):
self.blockSignals(True)
self.datamap.itemDelegateForRow(
self.datamap.rowCount()-1).setItemsByIndex(0, self.entitys)
if self.Equipment.status:
self.datamap.setEnabled(True)
self.filename.setText(self.Equipment.kwargs["filename"])
self.datamap.itemDelegateForRow(0).setItemsByIndex(
3, self.Equipment.sheets)
self.datamap.blockSignals(True)
self.datamap.clear()
if self.Equipment.kwargs["datamap"]:
for i, data in enumerate(self.Equipment.kwargs["datamap"]):
self.datamap.addRow()
self.datamap.itemDelegateForRow(i).setItemsByIndex(
0, self.entitys)
self.datamap.itemDelegateForRow(i).setItemsByIndex(
3, self.Equipment.sheets)
self.datamap.setItem(
i, 0, QtWidgets.QTableWidgetItem(data["entity"]))
self.datamap.setItem(
i, 1, QtWidgets.QTableWidgetItem(data["property"]))
self.datamap.setItem(
i, 2, QtWidgets.QTableWidgetItem(data["unit"]))
self.datamap.setItem(
i, 3, QtWidgets.QTableWidgetItem(data["sheet"]))
self.datamap.setItem(
i, 4, QtWidgets.QTableWidgetItem(data["cell"]))
self.datamap.itemDelegateForRow(
#.........这里部分代码省略.........