本文整理汇总了Python中UI.widgets.Tabla.setColumnWidth方法的典型用法代码示例。如果您正苦于以下问题:Python Tabla.setColumnWidth方法的具体用法?Python Tabla.setColumnWidth怎么用?Python Tabla.setColumnWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI.widgets.Tabla
的用法示例。
在下文中一共展示了Tabla.setColumnWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UI_equipment
# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import setColumnWidth [as 别名]
#.........这里部分代码省略.........
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(
self.datamap.rowCount()-1).setItemsByIndex(0, self.entitys)
self.datamap.itemDelegateForRow(
self.datamap.rowCount()-1).setItemsByIndex(
3, self.Equipment.sheets)
self.datamap.blockSignals(False)
self.blockSignals(False)
def rellenar(self):
self.rellenarInput()
self.status.setState(self.Equipment.status, self.Equipment.msg)
def cellChanged(self, i, j):
obj = self.project.getObject(str(self.datamap.item(i, 0).text()))
properties = [prop[0] for prop in obj.propertiesNames()]
if j == 0: # Entity cambiado, cambiar variables disponibles
self.datamap.itemDelegateForRow(i).setItemsByIndex(1, properties)
editor = QtWidgets.QComboBox()
editor.addItems(self.datamap.itemDelegateForRow(i).items[1])
self.datamap.setColumnWidth(1, editor.sizeHint().width())
elif j == 1: # Variable cambiada, cambiar unidades disponibles
value = self.datamap.item(i, 1).text()
ind = properties.index(value)
if obj.propertiesUnit()[ind] == str:
self.datamap.itemDelegateForRow(i).setItemsByIndex(2, [" "])
self.datamap.item(i, 2).setText(" ")
else:
self.datamap.itemDelegateForRow(i).setItemsByIndex(
2, obj.propertiesNames()[ind][2].__text__)
elif j == 3:
self.datamap.item(i, 4).setText("")
def addRow(self, fila):
datamap = self.Equipment.kwargs["datamap"][:]
data = {}
data["entity"] = str(fila[0])
data["property"] = str(fila[1])
data["unit"] = str(fila[2])
data["sheet"] = str(fila[3])
data["cell"] = str(fila[4])
datamap.append(data)
self.changeParams("datamap", datamap)