def _addRow(self, name, value): rc = self.frm.posTbl.rowCount() self.frm.posTbl.setRowCount(rc + 1) self.frm.posTbl.setItem(rc, 0, QTableWidgetItem(name)) self.frm.posTbl.setItem(rc, 1, QTableWidgetItem(value)) self.frm.posTbl.resizeColumnsToContents() self.frm.posTbl.resizeRowsToContents()
def configToFrame(frame, config): frame.nameBox.setText(config['name']) frame.commentBox.setText(config['comment']) frame.thickBox.setText(str(config['thickness'])) frame.posTbl.setRowCount(len(config['position'])) for i, (dev_name, position) in enumerate(config['position'].items()): frame.posTbl.setItem(i, 0, QTableWidgetItem(dev_name)) frame.posTbl.setItem(i, 1, QTableWidgetItem(str(position))) frame.posTbl.resizeRowsToContents() frame.posTbl.resizeColumnsToContents()
def configToFrame(frame, config): frame.nameBox.setText(config['name']) frame.commentBox.setText(config['comment']) frame.offsetBox.setText(str(config['detoffset'])) frame.thickBox.setText(str(config['thickness'])) frame.factorBox.setText(str(config['timefactor'])) frame.posTbl.setRowCount(len(config['position'])) frame.apXBox.setText(str(config['aperture'][0])) frame.apYBox.setText(str(config['aperture'][1])) frame.apWBox.setText(str(config['aperture'][2])) frame.apHBox.setText(str(config['aperture'][3])) for i, (devname, position) in enumerate(iteritems(config['position'])): frame.posTbl.setItem(i, 0, QTableWidgetItem(devname)) frame.posTbl.setItem(i, 1, QTableWidgetItem(str(position))) frame.posTbl.resizeRowsToContents() frame.posTbl.resizeColumnsToContents()
def _set_first_positions(self, dialog): values = self._get_first_position_values(dialog) if not values: return _table = self.frame.firstPosTable for i in range(_table.rowCount()): for j in (0, 1): _item = QTableWidgetItem(values[i][j]) _table.setItem(i, j, _item)
def addRow(self, dic): if self._edit: self._stopEdit() self._rows.append(dic) last = self.table.rowCount() self.table.setRowCount(last + 1) for i, (eltype, _) in enumerate(self.measdef.getElements()): item = QTableWidgetItem(dic[eltype].getDispValue()) self.table.setItem(last, i, item) self.table.resizeRowsToContents()
def addRow(self, elements=None): if self._edit: self._stopEdit() last = self.table.rowCount() self.table.setRowCount(last + 1) if elements is None: elements = [Device(dev, self.client) for dev in self.devs] for (i, element) in enumerate(elements): self.table.setItem(last, i, QTableWidgetItem(element.getDispValue())) self._rows.append(elements) self.table.resizeRowsToContents()
def _update_device(self, devname): try: parlist = self.client.eval('session.getDevice(%r)._dev.' 'ListParams()' % devname) cmdlist = self.client.eval('session.getDevice(%r)._dev.' 'ListCmds()' % devname) except Exception: QMessageBox.warning( self, 'Error', 'Could not retrieve the param/' 'command list from device.') return self.controlBox.setEnabled(True) self._par_values = {} self._changed_pars = {} self.paramTable.clear() self.paramTable.setColumnCount(2) self.paramTable.setRowCount(len(parlist)) for (i, par) in enumerate(parlist): nameitem = QTableWidgetItem(par) nameitem.setFlags(nameitem.flags() & ~Qt.ItemIsEditable) self.paramTable.setItem(i, 0, nameitem) value = self.client.eval('session.getDevice(%r)._dev.' 'GetParam(%r)' % (devname, par), default=None) valuestr = '<error>' if value is None else '%.6g' % value self._par_values[par] = valuestr self.paramTable.setItem(i, 1, QTableWidgetItem(valuestr)) self.paramTable.resizeRowsToContents() self.paramTable.resizeColumnToContents(0) self.cmdList.clear() for cmd in cmdlist: QListWidgetItem(cmd, self.cmdList)
def on_client_connected(self): self.clear() self.table.setRowCount(len(bit_description)) for m in range(len(bit_description)): for n in [0, 1]: newitem = QTableWidgetItem() self.table.setItem(m, n, newitem) self.table.item(m, 1).setText(bit_description[m]) params = self.client.getDeviceParams(self.devname) if params: value = params.get('value') if value: self._update_table(value)
def __init__(self, parent, validator, curvalue, fmtstr, client, allow_enter=False): self._rows, self._cols = curvalue.shape self.validator = validator QTableWidget.__init__(self, self._rows, self._cols, parent) for i in range(self._rows): for j in range(self._cols): self.setItem(i, j, QTableWidgetItem(fmtstr % curvalue[i, j])) self.cellChanged.connect(lambda i, j: self.valueModified.emit())
def updateTable(self): self.table.setRowCount(0) table = self.measdef.getTable() if not table: return first = table[0] self.table.setRowCount(len(table)) self.table.setColumnCount(len(first)) self.table.setHorizontalHeaderLabels(first.keys()) total_time = 0 for i, entry in enumerate(table): for j, element in enumerate(entry.values()): item = QTableWidgetItem(element.getDispValue()) self.table.setItem(i, j, item) if element.eltype == 'time': total_time += element.getValue() self.table.resizeRowsToContents() self.totalTime.setText(formatDuration(total_time)) self.changed()
def __init__(self, value): QTableWidgetItem.__init__(self, str(value)) self.value = value
def setColumnHeaders(self, column_headers): self.setColumnCount(len(column_headers)) for i, text in enumerate(column_headers): self.setHorizontalHeaderItem(i, QTableWidgetItem(text))
def setCurrentDataset(self, plot): if self.currentPlot: self.plotLayout.removeWidget(self.currentPlot) self.currentPlot.hide() self.metaTable.clearContents() self.currentPlot = plot if plot is None: self.enablePlotActions(False) else: try: self.setUidStack.remove(plot.dataset.uid) except ValueError: pass self.setUidStack.append(plot.dataset.uid) num_items = 0 for catname in INTERESTING_CATS: if catname in plot.dataset.headerinfo: num_items += 2 + len(plot.dataset.headerinfo[catname]) num_items -= 1 # remove last empty row self.metaTable.setRowCount(num_items) i = 0 for catname in INTERESTING_CATS: if catname in plot.dataset.headerinfo: values = plot.dataset.headerinfo[catname] catdesc = catname for name_desc in INFO_CATEGORIES: if name_desc[0] == catname: catdesc = name_desc[1] catitem = QTableWidgetItem(catdesc) font = catitem.font() font.setBold(True) catitem.setFont(font) self.metaTable.setItem(i, 0, catitem) self.metaTable.setSpan(i, 0, 1, 2) i += 1 for dev, name, value in sorted(values): key = '%s_%s' % (dev, name) if name != 'value' else dev self.metaTable.setItem(i, 0, QTableWidgetItem(key)) self.metaTable.setItem(i, 1, QTableWidgetItem(value)) if self.metaTable.columnSpan(i, 0) == 2: self.metaTable.setSpan(i, 0, 1, 1) i += 1 i += 1 self.metaTable.resizeRowsToContents() self.enablePlotActions(True) self.enableAutoScaleActions(self.currentPlot.HAS_AUTOSCALE) self.datasetList.setCurrentItem(self.setitems[plot.dataset.uid]) self.actionXAxis.setText('X axis: %s' % plot.current_xname) self.actionNormalized.setChecked(bool(plot.normalized)) self.actionLogScale.setChecked(plot.isLogScaling()) self.actionLogXScale.setChecked(plot.isLogXScaling()) self.actionLegend.setChecked(plot.isLegendEnabled()) self.actionErrors.setChecked(plot.isErrorBarEnabled()) if plot.HAS_AUTOSCALE: from gr.pygr import PlotAxes mask = plot.plot.autoscale self._autoscale(x=mask & PlotAxes.SCALE_X, y=mask & PlotAxes.SCALE_Y) plot.logYinDomain.connect(self.on_logYinDomain) plot.logXinDomain.connect(self.on_logXinDomain) self.plotLayout.addWidget(plot) plot.show()
def _configure_item(): item = QTableWidgetItem(str(0.0)) item.setFlags(Qt.ItemIsEnabled) item.setBackground(Qt.lightGray) return item
def _create_table_widget(self, value): return QTableWidgetItem('%s' % value)