Пример #1
0
 def populate_usrn_table(self, esu_id):
     """
     Populate the esu_id selector table widget with all linked usrn's
     :param esu_id: ESU ID
     """
     street_records = self.query_for_usrn(esu_id)
     if street_records:
         # Set esu_id label text
         esu_label = self.street_sel_dlg.ui.esuLabel
         esu_label.setText(str("ESU: " + str(esu_id)))
         table_widget = self.street_sel_dlg.ui.usrnTableWidget
         # Clear table
         self.reset_table(table_widget)
         row_count = table_widget.rowCount()
         # loop to populate records
         for record in street_records:
             col = 0
             table_widget.insertRow(row_count)
             for item in record:
                 t_item = QTableWidgetItem()
                 t_item.setText(str(item))
                 item_color = QColor(213, 234, 234)
                 t_item.setBackgroundColor(item_color)
                 t_item.setSelected(True)
                 self.street_sel_dlg.ui.usrnTableWidget.setItem(
                     row_count, col, t_item)
                 col += 1
             row_count += 1
         table_widget.selectRow(0)
         self.street_sel_dlg.exec_()
     else:
         pass
Пример #2
0
 def populateFieldTable(self):
     if self.collectedDataDict:
         importingFields = self.collectedDataDict[0].keys()
         self.fieldTable.clear()
         self.fieldTable.setRowCount(len(importingFields))
         predefinedFields = ['EOMETRY','ODKUUID']
         for row,field in enumerate(importingFields):
             enabledItem = QTableWidgetItem()
             enabledItem.setFlags(enabledItem.flags() | Qt.ItemIsUserCheckable)
             enabledItem.setText("")
             self.fieldTable.setItem(row,0,enabledItem)
             ODKfieldItem = QTableWidgetItem()
             ODKfieldItem.setText(field)
             self.fieldTable.setItem(row,1,ODKfieldItem)
             self.fieldTable.setRowHeight(row,30)
             QGISfieldItem = QTableWidgetItem()
             if slugify(field) in self.fieldMapping:
                 QGISfieldItem.setText(self.fieldMapping[slugify(field)])
                 enabledItem.setCheckState(Qt.Checked)
             else:
                 QGISfieldItem.setText("")
                 enabledItem.setCheckState(Qt.Unchecked)
             self.fieldTable.setItem(row,2,QGISfieldItem)
             if field[-7:] in predefinedFields: #prevent predefined fields user editing
                 if field[-7:] == 'ODKUUID':
                     ODKfieldItem.setText('ODKUUID')
                 enabledItem.setCheckState(Qt.Checked)
                 enabledItem.setFlags(enabledItem.flags() & Qt.ItemIsEditable)
                 ODKfieldItem.setFlags(ODKfieldItem.flags() & Qt.ItemIsEditable)
                 QGISfieldItem.setFlags(QGISfieldItem.flags() & Qt.ItemIsEditable)
    def _show_node_information(self, node):
        
        # hide all rows
        for r in range(self.info_table.rowCount()):
            self.info_table.setRowHidden(r, True)
        
        # add new information save dict[ecu_id][settings_id] = row_nr
        comp_id = node.settings_dict['comp_id']      
        self.selection_label.setText("Selected ECU:      %s" % comp_id)

        for set_key in node.settings_dict.keys():
            
            # if already exists -> show its row and skip
            try: 
                row_nr = self._show_dict[comp_id][set_key]
                self.info_table.setRowHidden(row_nr, False)
                continue
            except: pass
                        
            # else add it to table and show row
            self.info_table.setRowCount(self.info_table.rowCount() + 1)
            row_nr = self.info_table.rowCount()          
            item_1 = QTableWidgetItem()
            item_1.setData(QtCore.Qt.EditRole, set_key)  
            item_2 = QTableWidgetItem()
            item_2.setText(str(node.settings_dict[set_key]));  
            General().add_to_three_dict(self._show_dict, comp_id, set_key, row_nr)            
            self.info_table.setItem(row_nr - 1, 0, item_1)
            self.info_table.setItem(row_nr - 1, 1, item_2)
            self.info_table.setRowHeight(row_nr - 1, 20)
Пример #4
0
    def setTableContent(self):
        numOutputs = 0
        for output in self.alg.outputs:
            if isinstance(output, (OutputVector, OutputRaster)):
                if not output.hidden:
                    numOutputs += 1
        self.tblStyles.setRowCount(numOutputs)

        i = 0
        for output in self.alg.outputs:
            if isinstance(output, (OutputVector, OutputRaster)):
                if not output.hidden:
                    item = QTableWidgetItem(output.description + '<' +
                                            output.__class__.__name__ + '>')
                    item.setFlags(Qt.ItemIsEnabled)
                    self.tblStyles.setItem(i, 0, item)
                    item = RenderingStyleFilePanel()
                    style = \
                        RenderingStyles.getStyle(self.alg.commandLineName(),
                                                 output.name)
                    if style:
                        item.setText(unicode(style))
                    self.valueItems[output.name] = item
                    self.tblStyles.setCellWidget(i, 1, item)
                    self.tblStyles.setRowHeight(i, 22)
            i += 1
Пример #5
0
    def _show_node_information(self, node):

        # hide all rows
        for r in range(self.info_table.rowCount()):
            self.info_table.setRowHidden(r, True)

        # add new information save dict[ecu_id][settings_id] = row_nr
        comp_id = node.settings_dict['comp_id']
        self.selection_label.setText("Selected ECU:      %s" % comp_id)

        for set_key in node.settings_dict.keys():

            # if already exists -> show its row and skip
            try:
                row_nr = self._show_dict[comp_id][set_key]
                self.info_table.setRowHidden(row_nr, False)
                continue
            except:
                pass

            # else add it to table and show row
            self.info_table.setRowCount(self.info_table.rowCount() + 1)
            row_nr = self.info_table.rowCount()
            item_1 = QTableWidgetItem()
            item_1.setData(QtCore.Qt.EditRole, set_key)
            item_2 = QTableWidgetItem()
            item_2.setText(str(node.settings_dict[set_key]))
            General().add_to_three_dict(self._show_dict, comp_id, set_key,
                                        row_nr)
            self.info_table.setItem(row_nr - 1, 0, item_1)
            self.info_table.setItem(row_nr - 1, 1, item_2)
            self.info_table.setRowHeight(row_nr - 1, 20)
Пример #6
0
    def on_pbnRemoveIndicator_released(self):
        row = self.twIndicatorsToVisualize.currentRow()

        cur_item = self.twIndicatorsToVisualize.item(row, 0)
        if cur_item is not None:
            value = str(cur_item.text())

            item = QTableWidgetItem(
                value)  #need to create new item because QT deletes object
            last_row = self.twAvailableIndicators.rowCount()
            indicator = self.indicator_nodes[value]
            new_row = QTableWidgetItem()
            self.twAvailableIndicators.setRowCount(last_row + 1)
            self.twAvailableIndicators.setVerticalHeaderItem(last_row, new_row)

            self.twAvailableIndicators.setItem(last_row, 0, item)

            item = QTableWidgetItem()
            item.setText(indicator.get('name'))
            self.twAvailableIndicators.setItem(last_row, 1, item)

#            item = QTableWidgetItem()
#            item.setText(indicator['value'])
#            self.twAvailableIndicators.setItem(last_row,2,item)

        self.twIndicatorsToVisualize.removeRow(row)
    def on_pbnRemoveIndicator_clicked(self):
        row = self.twIndicatorsToVisualize.currentRow()

        cur_item = self.twIndicatorsToVisualize.item(row, 0)
        if cur_item is not None:
            value = str(cur_item.text())

            item = QTableWidgetItem(value) #need to create new item because QT deletes object
            last_row = self.twAvailableIndicators.rowCount()
            indicator = self.indicator_nodes[value]
            new_row = QTableWidgetItem()
            self.twAvailableIndicators.setRowCount(last_row + 1)
            self.twAvailableIndicators.setVerticalHeaderItem(last_row,new_row)

            self.twAvailableIndicators.setItem(last_row,0,item)

            item = QTableWidgetItem()
            item.setText(indicator.text or '')
            self.twAvailableIndicators.setItem(last_row,1,item)

#            item = QTableWidgetItem()
#            item.setText(indicator['value'])
#            self.twAvailableIndicators.setItem(last_row,2,item)

        self.twIndicatorsToVisualize.removeRow(row)
Пример #8
0
 def on_AddButton_2_clicked(self):
     """
     Now it's time to add those files we were avoiding to emiting extra signals, right? xD
     """
     files = QFileDialog.getOpenFileNames(\
         None,
         self.trUtf8("Select files to add to the convert queue"),
         self.settings.value("lastphotodir",QVariant(os.path.expanduser("~"))).toString(),
         QString(),
         None) # A cute QFileDialog asks the user for the files to convert, for both videos and images.
     if not files.isEmpty(): #If nothing, do nothing.
         try:
             self.settings.setValue("lastphotodir", QVariant(os.path.split(toPython(files[0]))[0]))
             #Remembering last used dir comes always in handy.
         except:
             print files #Debugging stuff...
     for file in files:
         currentrow = self.tableWidget_2.rowCount()
         self.tableWidget_2.insertRow(currentrow)
         filewidget = QTableWidgetItem()
         filewidget.setText(file)
         try:
             filewidget.setIcon(QIcon(file))
         except:
             print "Could not load a thumbnail of the album art"
         outputitem = QTableWidgetItem()
         outputitem.setText(self.output)
         self.tableWidget_2.setItem(currentrow,0,filewidget)
         self.tableWidget_2.setItem(currentrow,1,outputitem)
         self.tableWidget_2.resizeColumnsToContents()
Пример #9
0
    def add_new_table(self, rel, name):
        import itertools

        table = QTableWidget()
        table.setRowCount(0)
        table.setColumnCount(0)

        data = itertools.chain([rel.fields], rel.content)

        for row_data in data:
            row = table.rowCount()
            table.setColumnCount(len(row_data))
            for col, text in enumerate(row_data):
                item = QTableWidgetItem()
                item.setText(text)
                if row == 0:
                    table.setHorizontalHeaderItem(col, item)
                else:
                    table.setItem(row - 1, col, item)
            table.insertRow(row)
        table.removeRow(table.rowCount() - 1)
        self.stacked.addWidget(table)
        self.stacked.setCurrentIndex(self.stacked.count() - 1)
        lateral = Pireal.get_service("lateral")
        lateral.add_item_list([name])
Пример #10
0
    def filltWTasksView(self, tasks):

        rowCount = len(tasks)
        self.ui.tWTasks.setRowCount(rowCount)
        row = 0
        for taskname, task in tasks.items():
            item = QTableWidgetItem()
            item.setText(task.taskName)
            self.ui.tWTasks.setItem(row, 0, item)

            item = QtGui.QTableWidgetItem()
            item.setText(unicode(task.storeName))
            self.ui.tWTasks.setItem(row, 1, item)

            item = QtGui.QTableWidgetItem()
            item.setText(task.reservType)
            self.ui.tWTasks.setItem(row, 2, item)

            item = QtGui.QTableWidgetItem()
            item.setText(task.proxyServer)
            self.ui.tWTasks.setItem(row, 3, item)

            item = QtGui.QTableWidgetItem()
            item.setText(task.proxyPort)
            self.ui.tWTasks.setItem(row, 4, item)
            row += 1
 def __init__(self):
     QMainWindow.__init__(self)
     self.ui= Ui_estadisticas()
     self.ui.setupUi(self)
     self.ui.pBCancelar.clicked.connect(self.onPushbuttonClicked)
     self.ui.twEstadisticas.setColumnCount(2)
     headers=["Jugadores","Tiempo"]
     self.ui.twEstadisticas.setHorizontalHeaderLabels(headers)
     archivo=open("Ganadores.txt","r")
     linea=archivo.readline()
     partida=linea.split(",")
     nombreG=partida[0]
     cronometro=partida[1]
     j=0
     while linea!="": 
         self.ui.twEstadisticas.insertRow( self.ui.twEstadisticas.rowCount() )
         partida=linea.split(",")
         nombreG=partida[0]
         cronometro=partida[1] 
         item1 = QTableWidgetItem()
         item2 = QTableWidgetItem()  
         item1.setText("%s" % nombreG )
         item2.setText("%s" % cronometro) 
         self.ui.twEstadisticas.setItem(j,0, item1)
         self.ui.twEstadisticas.setItem(j,1, item2)
         j=j+1
         linea=archivo.readline()        
Пример #12
0
    def filltWTasksView(self, tasks):

        rowCount = len(tasks)
        self.ui.tWTasks.setRowCount(rowCount)
        row = 0
        for taskname, task in tasks.items():
            item = QTableWidgetItem()
            item.setText(task.taskName)
            self.ui.tWTasks.setItem(row, 0, item)

            item = QtGui.QTableWidgetItem()
            item.setText(unicode(task.storeName))
            self.ui.tWTasks.setItem(row, 1, item)

            item = QtGui.QTableWidgetItem()
            item.setText(task.reservType)
            self.ui.tWTasks.setItem(row, 2, item)

            item = QtGui.QTableWidgetItem()
            item.setText(task.proxyServer)
            self.ui.tWTasks.setItem(row, 3, item)

            item = QtGui.QTableWidgetItem()
            item.setText(task.proxyPort)
            self.ui.tWTasks.setItem(row, 4, item)
            row += 1
    def setTableContent(self):
        numOutputs = 0
        for output in self.alg.outputs:
            if isinstance(output, (OutputVector, OutputRaster)):
                if not output.hidden:
                    numOutputs += 1
        self.tblStyles.setRowCount(numOutputs)

        i = 0
        for output in self.alg.outputs:
            if isinstance(output, (OutputVector, OutputRaster)):
                if not output.hidden:
                    item = QTableWidgetItem(output.description + '<'
                            + output.__class__.__name__ + '>')
                    item.setFlags(Qt.ItemIsEnabled)
                    self.tblStyles.setItem(i, 0, item)
                    item = RenderingStyleFilePanel()
                    style = \
                        RenderingStyles.getStyle(self.alg.commandLineName(),
                            output.name)
                    if style:
                        item.setText(unicode(style))
                    self.valueItems[output.name] = item
                    self.tblStyles.setCellWidget(i, 1, item)
                    self.tblStyles.setRowHeight(i, 22)
            i += 1
Пример #14
0
    def addHeaders(self):
        headerItem = QTableWidgetItem()
        headerItem.setText(QApplication.translate("applyModule", "Name", None, QApplication.UnicodeUTF8))
        self.setHorizontalHeaderItem(0,headerItem)

        headerItem1 = QTableWidgetItem()
        headerItem1.setText(QApplication.translate("applyModule", "Tags", None, QApplication.UnicodeUTF8))
        self.setHorizontalHeaderItem(1,headerItem1)
Пример #15
0
 def changeHabColor(self):
     currRow = self.habTableWidget.currentRow()
     color_item = QTableWidgetItem()
     new_qcolor = QColorDialog.getColor(parent=self)
     if new_qcolor.isValid():
         color_item.setBackgroundColor( new_qcolor )
         color_item.setText( new_qcolor.name() )
         self.habTableWidget.setItem(currRow,2,color_item)
Пример #16
0
 def changeHabColor(self):
     currRow = self.habTableWidget.currentRow()
     color_item = QTableWidgetItem()
     new_qcolor = QColorDialog.getColor(parent=self)
     if new_qcolor.isValid():
         color_item.setBackgroundColor(new_qcolor)
         color_item.setText(new_qcolor.name())
         self.habTableWidget.setItem(currRow, 2, color_item)
Пример #17
0
    def __init__(self, actions, parent=None):
    
        super(ActionEditorDialog, self).__init__(parent)
        self.actions = actions

        help = QLabel(translate("Shortcut Settings", '<b>Double click a cell in the Shortcut Column' \
            ' to <br />modify the key sequence.</b>'))
        
        self.actionTable = QTableWidget(self)
        self.actionTable.setSelectionBehavior(QTableWidget.SelectRows)
        self.actionTable.setEditTriggers(QTableWidget.DoubleClicked)
        self.actionTable.setColumnCount(2)
        self.actionTable.setHorizontalHeaderLabels(
            [translate("Shortcut Settings", "Description"),
            translate("Shortcut Settings", "Shortcut")]
            )
        self.actionTable.horizontalHeader().setStretchLastSection(True)
        self.actionTable.verticalHeader().hide()
        self.actionTable.setItemDelegate(ActionEditorDelegate(self))
        
        self.connect(self.actionTable, SIGNAL("cellChanged(int, int)"),
                     self.validateAction)
        
        row = 0
        for action in self.actions:
        
            if action.text().isEmpty():
                continue
            
            self.actionTable.insertRow(self.actionTable.rowCount())
            
            item = QTableWidgetItem()
            item.setText(action.text())
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            self.actionTable.setItem(row, 0, item)
            
            item = QTableWidgetItem()
            item.setText(action.shortcut().toString())
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable)
            item.oldShortcutText = item.text()
            self.actionTable.setItem(row, 1, item)
            
            row += 1
        
        self.actionTable.resizeColumnsToContents()
                
        mainLayout = QVBoxLayout()
        mainLayout.addWidget(help)
        mainLayout.setMargin(8)
        mainLayout.setSpacing(8)
        mainLayout.addWidget(self.actionTable)
        self.setLayout(mainLayout)
        self._model = self.actionTable.model()
        self._model.edited = False
        self.actionTable.model().edited = False
        
        self.setWindowTitle(translate("Shortcut Settings", "Edit Shortcuts"))
Пример #18
0
 def showTags(self, row, col):
     for i in range(3):
         print i
         it = self.tagsTable.item(i, 0)
         if it is None: 
             print "New an item at ", i, 0
             it = QTableWidgetItem("tags: %d (%d,%d)" % (i, row, col))
             self.tagsTable.setItem(i, 0, it)
         else:
             print "Existing item", i, 0
             it.setText("this is a very long tags: %d (%d,%d)" % (i, row, col))
Пример #19
0
    def horizontalHeaders(self, horizontalHeaders):
        """Set horizontal headers in the table list."""

        self._horizontalHeaders = horizontalHeaders

        self.tableWidget.setColumnCount(len(horizontalHeaders))
        self.tableWidget.horizontalHeader().setVisible(True)

        for idx, header in enumerate(horizontalHeaders):
            item = QTableWidgetItem()
            item.setText(header)
            self.tableWidget.setHorizontalHeaderItem(idx, item)
Пример #20
0
    def update(self, resultSet):
        h = resultSet.head()
        r = resultSet.getDataset()

        for i in range(len(h)):
            a = QTableWidgetItem()
            a.setText(h[i])
            self.pyqtTable.setHorizontalHeaderItem(i, a)
            for j in range(len(r)):
                b = QTableWidgetItem()
                b.setText(unicode(str(r[j][i]), "gb2312"))
                self.pyqtTable.setItem(j, i, b)
Пример #21
0
    def fillHeader(self, row, chain):
        item = chain.createTableWidgetItem()
        self.table.setSpan(row, 0, 1, 3)
        self.table.setItem(row, 0, item)

        item = QTableWidgetItem()
        unsetFlag(item, Qt.ItemIsEditable)
        item.setText(tr("Translated to"))
        item.setTextAlignment(Qt.AlignHCenter)
        item.setBackgroundColor(DECISION_COLORS['ACCEPT'])
        self.table.setSpan(row, 4, 1, 3)
        self.table.setItem(row, 4, item)
Пример #22
0
    def horizontalHeaders(self, horizontalHeaders):
        """Set horizontal headers in the table list."""

        self._horizontalHeaders = horizontalHeaders

        self.tableWidget.setColumnCount(len(horizontalHeaders))
        self.tableWidget.horizontalHeader().setVisible(True)

        for idx, header in enumerate(horizontalHeaders):
            item = QTableWidgetItem()
            item.setText(header)
            self.tableWidget.setHorizontalHeaderItem(idx, item)
Пример #23
0
    def addHeaders(self):
        headerItem = QTableWidgetItem()
        headerItem.setText(
            QApplication.translate("applyModule", "Name", None,
                                   QApplication.UnicodeUTF8))
        self.setHorizontalHeaderItem(0, headerItem)

        headerItem1 = QTableWidgetItem()
        headerItem1.setText(
            QApplication.translate("applyModule", "Tags", None,
                                   QApplication.UnicodeUTF8))
        self.setHorizontalHeaderItem(1, headerItem1)
Пример #24
0
    def update(self, resultSet):
        h = resultSet.head()
        r = resultSet.getDataset()

        for i in range(len(h)):
            a = QTableWidgetItem()
            a.setText(h[i])
            self.pyqtTable.setHorizontalHeaderItem(i, a)
            for j in range(len(r)):
                b = QTableWidgetItem()
                b.setText(unicode(str(r[j][i]), 'gb2312'))
                self.pyqtTable.setItem(j, i, b)
Пример #25
0
    def load_table(self, visualization, limit=10000):

        storage = StorageFactory().get_storage(
            type='%s_storage' % visualization.output_type,
            storage_location=visualization.storage_location)
        table_data = storage.load_table(table_name=visualization.table_name)

        try:
            primary_keys = visualization.indicators[0].primary_keys
        except:
            primary_keys = []

        keys = primary_keys + [
            key for key in table_data.keys() if key not in primary_keys
        ]
        num_rows = min(len(table_data[keys[0]]), limit)
        num_cols = len(keys)

        self.tableWidget.clear()
        self.tableWidget.setColumnCount(num_cols)
        self.tableWidget.setRowCount(num_rows)

        j = 0
        for key in keys:
            col = QTableWidgetItem()
            col.setText(QString(key))
            self.tableWidget.setHorizontalHeaderItem(j, col)
            j += 1

        self.tableWidget.resizeColumnsToContents()

        order = sorted(enumerate(table_data[keys[0]]), lambda (i, v),
                       (j, v2): int(v * 100) - int(v2 * 100))

        for i, (idx, v) in enumerate(order):
            row = QTableWidgetItem()
            self.tableWidget.setVerticalHeaderItem(i, row)
            j = 0
            for key in keys:
                item = QTableWidgetItem()
                item.setText(QString(str(table_data[key][idx])))
                self.tableWidget.setItem(i, j, item)
                j += 1
            if i > limit:
                msg = 'The table %s has been truncated to %i rows because of memory limitations.' % (
                    visualization.table_name, limit)
                detailed_msg = '<qt>To view the full results, open the following file:<br><br><small>%s</small></qt>' % visualization.get_file_path(
                )
                MessageBox.warning(mainwindow=self,
                                   text=msg,
                                   detailed_text=detailed_msg)
                break
Пример #26
0
    def load_worksheet(self, xsheet):
        """
        Loads worksheet data into the table.
        :param xsheet: Object containing worksheet data.
        :type xsheet: xlrd.sheet.Sheet
        """
        if not xsheet:
            QMessageBox.critical(
                self.parentWidget(), self.tr('Null Sheet'),
                self.tr('Sheet object is None, cannot be loaded.'))
            return

        self._ws = xsheet
        self._ncols = self._ws.ncols
        self._nrows = self._ws.nrows

        # Update view
        self._update_view()

        # Add cell values
        tbi = None
        for r in range(self._nrows):
            for c in range(self._ncols):
                tbi = QTableWidgetItem()
                cell = self._ws.cell(r, c)
                val = cell.value
                # Number
                if cell.ctype == 2:
                    val = str(float(val))

                # Date/time
                elif cell.ctype == 3:
                    try:
                        dt = xldate_as_tuple(val, self._ws.book.datemode)
                        val_dt = datetime(*dt)
                        # Apply formatting for the date/time
                        val = val_dt.strftime(self._date_format)
                    except XLDateError as de:
                        self.format_error_cell(tbi)
                        val = u'DATE ERROR!'

                # Boolean
                elif cell.ctype == 4:
                    val = 'True' if val == 1 else 'False'

                # Error with Excel codes
                elif cell.ctype == 5:
                    self.format_error_cell(tbi)
                    val = u'ERROR - {0}'.format(str(val))

                tbi.setText(val)
                self.setItem(r, c, tbi)
Пример #27
0
 def updateSwitcherTable(self,sw):
     """
     Uaktualnienie wiersza w tabeli zwrotnic odnoszącego sie do wskazanej zwotnicy.
     :param sw: obiekt klasy Switcher
     :return: None
     """
     rows = self.switchTable.rowCount()
     for i in range(0,rows,1):
         if int(self.switchTable.item(i, 1).text()) == sw.deviceNo and sw.zone == self.switchTable.item(i, 3).text():
             item2 = QTableWidgetItem()
             item2.setText(sw.state.__str__())
             self.switchTable.setItem(i,2,item2)
             break
     print("SWITCHER CHANGED")
Пример #28
0
    def populateHeadersTable(self):
        self.g_headers.clear()
        self.g_headers.setSortingEnabled(False)
        self.g_headers.setAlternatingRowColors(True)
        self.g_headers.setHorizontalHeaderLabels(["Headers"])
        self.g_headers.setRowCount(
            len(self.config.headers[self.config.lenOrgHeaders:]))
        for i, it in enumerate(self.config.headers[self.config.lenOrgHeaders:]):
            item = QTableWidgetItem()
            item.setText(it)
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            self.g_headers.setItem(i, 0, item)

        self.g_headers.resizeColumnsToContents()
Пример #29
0
    def showResult(self):
        for i in xrange(self.programLogic.inputCount()):
            itemInputNumber = QTableWidgetItem()
            itemInputNumber.setText(str(i + 1))
            itemInputNumber.setTextAlignment(Qt.AlignCenter)
            itemInputNumber.setFlags(Qt.ItemIsEnabled)
            self.uiDataBefore.setItem(0, i, itemInputNumber)

            itemOriginalInputs = QTableWidgetItem()
            originalInput = self.programLogic.currentInputs()[i]
            itemOriginalInputs.setText(self.formatNumber(originalInput))
            itemOriginalInputs.setTextAlignment(Qt.AlignCenter)
            itemOriginalInputs.setFlags(Qt.ItemIsEnabled)
            self.uiDataBefore.setItem(1, i, itemOriginalInputs)

            itemNormalizedInputs = QTableWidgetItem()
            itemNormalizedInputs.setText(self.formatNumber(self.programLogic.currentNormalizedInputs()[i]))
            itemNormalizedInputs.setTextAlignment(Qt.AlignCenter)
            itemNormalizedInputs.setFlags(Qt.ItemIsEnabled)
            self.uiDataBefore.setItem(2, i, itemNormalizedInputs)

            itemWeights = QTableWidgetItem()
            itemWeights.setText(self.formatNumber(self.programLogic.currentPrevWeights()[i]))
            itemWeights.setTextAlignment(Qt.AlignCenter)
            itemWeights.setFlags(Qt.ItemIsEnabled)
            self.uiDataBefore.setItem(3, i, itemWeights)

        self.uiLabelComment.setText('Comment: ' + self.programLogic.currentComment())
        self.uiCorrectBefore.setText(str(self.programLogic.currentExpectedOutput()))
    def load_table(self, visualization, limit = 10000):

        storage = StorageFactory().get_storage(
                       type = '%s_storage'%visualization.output_type,
                       storage_location = visualization.storage_location)
        table_data = storage.load_table(
                                table_name = visualization.table_name)

        try:
            primary_keys = visualization.indicators[0].primary_keys
        except:
            primary_keys = []

        keys = primary_keys + [key for key in table_data.keys()
                                   if key not in primary_keys]
        num_rows = min(len(table_data[keys[0]]), limit)
        num_cols = len(keys)

        self.tableWidget.clear()
        self.tableWidget.setColumnCount(num_cols)
        self.tableWidget.setRowCount(num_rows)

        j = 0
        for key in keys:
            col = QTableWidgetItem()
            col.setText(QString(key))
            self.tableWidget.setHorizontalHeaderItem(j,col)
            j += 1

        self.tableWidget.resizeColumnsToContents()

        order = sorted(enumerate(table_data[keys[0]]), lambda (i,v),(j,v2): int(v*100)-int(v2*100))

        for i, (idx,v) in enumerate(order):
            row = QTableWidgetItem()
            self.tableWidget.setVerticalHeaderItem(i,row)
            j = 0
            for key in keys:
                item = QTableWidgetItem()
                item.setText(QString(str(table_data[key][idx])))
                self.tableWidget.setItem(i,j,item)
                j += 1
            if i > limit:
                msg = 'The table %s has been truncated to %i rows because of memory limitations.'%(visualization.table_name,limit)
                detailed_msg = '<qt>To view the full results, open the following file:<br><br><small>%s</small></qt>'%visualization.get_file_path()
                MessageBox.warning(mainwindow = self,
                                  text = msg,
                                  detailed_text = detailed_msg)
                break
Пример #31
0
    def load_qgs_vector_layer(self, vl):
        """
        Loads a QgsVectorLayer (created from Excel or CSV file) into the
        table.
        :param vl: Vector layer containing table information.
        :type vl: QgsVectorLayer
        """
        self._vl = vl
        dp = self._vl.dataProvider()
        self._nrows = dp.featureCount()
        self._ncols = len(dp.fieldNameMap())
        fields = self._vl.fields()

        # Update view
        self._update_view()

        # Add cell values
        tbi = None
        features = self._vl.getFeatures()
        ridx = 0

        for f in features:
            cidx = 0

            # Read attributes
            for fi in fields:
                tbi = QTableWidgetItem()
                attr = f.attribute(fi.name())
                # Correctly represent double values that are actually int
                if fi.type() == QVariant.Double:
                    if self._is_num(attr):
                        if attr.is_integer():
                            attr = int(attr)
                # Format string representation
                # Date
                if fi.type() == QVariant.Date:
                    try:
                        val = attr.strftime(self._date_format)
                    except AttributeError:
                        val = ''
                else:
                    val = unicode(attr)

                tbi.setText(val)
                self.setItem(ridx, cidx, tbi)

                cidx += 1

            ridx += 1
Пример #32
0
    def servoDataUpdate(self, servoId, addressOffset, servoData):
        if not self.servos.has_key(servoId):
            self.servoAdd(servoId)
        columnNumber = self.servos[servoId]['columnNumber']
        self.updating = True
        servoDataString = ('%c' * len(servoData)) % tuple(
            chr(c) for c in servoData)
        index = 0
        while index < len(servoDataString):
            fieldInfo = self.serialProtocol.memoryInfo[addressOffset + index]

            if fieldInfo['numElements'] != 1:
                self.log(
                    0,
                    'ERROR: MainWindow.servoDataUpdate(): numElements != 1 -> Arrays are not supported, yet...'
                )

            value = self.converter.fromString(servoDataString[index:],
                                              fieldInfo['type'])
            index += fieldInfo['size']

            # check if the item is being plotted
            subscribeId = '[%d].%s' % (servoId, fieldInfo['name'])
            if self.subscribedData.has_key(subscribeId):
                self.dataPlot.updateValue(subscribeId, float(value))

            # check for existing item, or create a new one
            dataItem = self.tableServoData.item(fieldInfo['index'],
                                                columnNumber)
            if not dataItem:
                dataItem = QTableWidgetItem()
                if fieldInfo['writable']:
                    dataItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable
                                      | Qt.ItemIsSelectable)
                else:
                    dataItem.setFlags(Qt.ItemFlag())
                self.tableServoData.setItem(fieldInfo['index'], columnNumber,
                                            dataItem)

            if type(value) == float:
                valueString = ('%.7f' % value).rstrip('0')
            else:
                valueString = str(value)
            dataItem.setText(valueString)  # update item text
            dataItem.setToolTip(
                fieldInfo['makeToolTip'](value))  # update item tool tip

        self.tableServoData.resizeColumnToContents(columnNumber)
        self.updating = False
Пример #33
0
    def add_table(self, rows, columns, name, data, fields):
        table = Table()
        table.setRowCount(rows)
        table.setColumnCount(columns)
        table.setHorizontalHeaderLabels(fields)

        for k, v in list(data.items()):
            item = QTableWidgetItem()
            item.setText(v)
            table.setItem(k[0] - 1, k[1], item)

        self.stacked.addWidget(table)
        self.stacked.setCurrentIndex(self.stacked.count() - 1)
        lateral = Pireal.get_service("lateral")
        lateral.add_item_list([name])
Пример #34
0
    def tablar(self,tabla,lista,head):
	    #Cumple la misma funcion que entablar, con la diferencia que esta recibe una lista de diccionarios 
	      tabla.clear()
	      tabla.setColumnCount(len(head))
	      tabla.setRowCount(len(lista))	 	 
	      for i,data in enumerate(head):
		  item = QTableWidgetItem(1)
		  item.setText(str(data))
		  tabla.setHorizontalHeaderItem(i,item)
	      for i,elem in enumerate(lista):
		  for j,data in enumerate(elem):
		    item = QTableWidgetItem(1)
		    item.setText(str(elem[data]))
		    tabla.setItem(i,j,item)
	      tabla.resizeColumnsToContents() 
Пример #35
0
 def updateSwitcherTable(self, sw):
     """
     Uaktualnienie wiersza w tabeli zwrotnic odnoszącego sie do wskazanej zwotnicy.
     :param sw: obiekt klasy Switcher
     :return: None
     """
     rows = self.switchTable.rowCount()
     for i in range(0, rows, 1):
         if int(self.switchTable.item(i, 1).
                text()) == sw.deviceNo and sw.zone == self.switchTable.item(
                    i, 3).text():
             item2 = QTableWidgetItem()
             item2.setText(sw.state.__str__())
             self.switchTable.setItem(i, 2, item2)
             break
     print("SWITCHER CHANGED")
Пример #36
0
 def enqueue_paths(self, files):
     try:
         self.settings.setValue("lastvideodir", QVariant(os.path.split(toPython(files[0]))[0]))
         #Remembering last used dir comes always in handy.
     except:
         print files #Debugging stuff...
     for file in files:
         currentrow = self.tableWidget.rowCount()
         self.tableWidget.insertRow(currentrow)
         filewidget = QTableWidgetItem()
         filewidget.setText(file)
         outputitem = QTableWidgetItem()
         outputitem.setText(self.output)
         self.tableWidget.setItem(currentrow,0,filewidget)
         self.tableWidget.setItem(currentrow,1,outputitem)
         self.tableWidget.resizeColumnsToContents()
Пример #37
0
 def createAttributeItems(self, fullTableName, currentDict, qmlDict, count, colour = None):
     """
     Creates a QTableWidgetItem for each attribute.
     The cell can have different types according to the data type used (i.e QCombobox, QLineEdit or QListWidget)
     """
     if fullTableName in currentDict.keys():
         for attr in currentDict[fullTableName]:
             self.attributeTableWidget.insertRow(count)
             item = QTableWidgetItem()
             item.setText(attr)
             if colour:
                 item.setBackgroundColor(colour)
             self.attributeTableWidget.setItem(count, 0, item)
             #creating the specific cell widget. It can be a QCombobox, a QLineEdit or a QListWidget
             self.createCellWidget(qmlDict, attr, count)
             count+=1
Пример #38
0
 def fillTableWidget(self, data, rowmax):
     self.ui.tableWidget.setColumnCount(len(data))
     self.ui.tableWidget.setRowCount(rowmax)
     index = 0
     for item in data:
         for name, times in item.items():
             item = QTableWidgetItem()
             item.setText(QString(name))
             self.ui.tableWidget.setHorizontalHeaderItem(index, item)
             i = 0
             for time, id in times:
                 item = QTableWidgetItem()
                 item.setText(QString(time))
                 self.ui.tableWidget.setItem(i, index, item)
                 self.contents['%s%s' % (i, index)] = id
                 i += 1
         index += 1
Пример #39
0
class TaskTableElem:
    ############################
    def __init__(self, id, status):
        self.id = id
        self.status = status
        self.progress = 0.0
        self.idItem = None
        self.progressBar = None
        self.progressBarInBoxLayoutWidget = None
        self.statusItem = None
        self.__buildRow()

    ############################
    def __buildRow(self):

        self.idItem = QTableWidgetItem()
        self.idItem.setText(self.id)

        self.progressBar = QProgressBar()
        self.progressBar.geometry().setHeight(20)
        self.progressBar.setProperty("value", 50)

        self.progressBarInBoxLayoutWidget = QWidget()
        boxLayout = QVBoxLayout()
        boxLayout.setMargin(3)
        boxLayout.addWidget(self.progressBar)

        self.progressBarInBoxLayoutWidget.setLayout(boxLayout)

        self.statusItem = QTableWidgetItem()
        self.statusItem.setText(self.status)

    ############################
    def setProgress(self, val):
        if val >= 0.0 and val <= 1.0:
            self.progress = val
        else:
            assert False, "Wrong progress setting {}".format(val)

    def getColumnItem(self, col):
        if col == 0:
            return self.idItem
        if col == 1:
            return self.statusItem

        assert False, "Wrong column index"
Пример #40
0
 def fillTableWidget(self, data, rowmax):
     self.ui.tableWidget.setColumnCount(len(data))
     self.ui.tableWidget.setRowCount(rowmax)
     index = 0
     for item in data:
         for name, times in item.items():
             item = QTableWidgetItem()
             item.setText(QString(name))
             self.ui.tableWidget.setHorizontalHeaderItem(index, item)
             i = 0
             for time, id in times:
                 item = QTableWidgetItem()
                 item.setText(QString(time))
                 self.ui.tableWidget.setItem(i, index, item)
                 self.contents['%s%s' % (i, index)] = id
                 i += 1
         index += 1
Пример #41
0
    def __insertRow(self, repoName, repoAddress):
        currentRow = self.settings.repoListView.rowCount()
        self.settings.repoListView.insertRow(currentRow)
        checkbox = QCheckBox(self.settings.repoListView)
        self.connect(checkbox, SIGNAL("toggled(bool)"), self.markChanged)
        self.settings.repoListView.setCellWidget(currentRow, 0, checkbox)
        self.settings.repoListView.cellWidget(currentRow, 0).setChecked(self.iface.isRepoActive(repoName))

        repoNameItem = QTableWidgetItem()
        repoNameItem.setText(repoName)
        repoNameItem.setTextAlignment(Qt.AlignLeft|Qt.AlignVCenter)
        self.settings.repoListView.setItem(currentRow, 1, repoNameItem)

        repoAddressItem = QTableWidgetItem()
        repoAddressItem.setText(repoAddress)
        repoAddressItem.setTextAlignment(Qt.AlignLeft|Qt.AlignVCenter)
        self.settings.repoListView.setItem(currentRow, 2, repoAddressItem)
Пример #42
0
    def load_relation(self, filenames=[]):
        """ Load relation from file """

        import csv
        from PyQt4.QtGui import QTableWidgetItem, QTableWidget
        from src.core import relation

        if not filenames:
            native_dialog = QFileDialog.DontUseNativeDialog
            directory = os.path.expanduser("~")
            ffilter = settings.RFILES.split(';;')[-1]
            filenames = QFileDialog.getOpenFileNames(self,
                                                     self.tr("Abrir Archivo"),
                                                     directory, ffilter,
                                                     native_dialog)
            if not filenames:
                return
        lateral = Pireal.get_service("lateral")
        for filename in filenames:
            rel = relation.Relation(filename)
            relation_name = os.path.splitext(os.path.basename(filename))[0]
            self.table_widget.relations[relation_name] = rel
            table = QTableWidget()
            with open(filename, newline='') as f:
                table.setRowCount(0)
                table.setColumnCount(0)
                csv_reader = csv.reader(f)
                for row_data in csv_reader:
                    row = table.rowCount()
                    table.setColumnCount(len(row_data))
                    for column, data in enumerate(row_data):
                        item = QTableWidgetItem()
                        item.setText(data)
                        if row == 0:
                            table.setHorizontalHeaderItem(column, item)
                        else:
                            table.setItem(row - 1, column, item)
                    table.insertRow(row)
                table.removeRow(table.rowCount() - 1)
            self.table_widget.stacked.addWidget(table)
        #FIXME: names
        names = [os.path.splitext(os.path.basename(i))[0]
                 for i in filenames]
        lateral.add_item_list(names)
        lateral.show()
Пример #43
0
 def initActions(self, actions, delegate):
     table = self.actionTable
     table.horizontalHeader().setStretchLastSection(True)
     table.verticalHeader().hide()
     table.setItemDelegate(delegate)
     for row, action in enumerate(actions):
         table.insertRow(table.rowCount())
         text = unicode(action.text()).replace('&', '')
         item = QTableWidgetItem(action.icon(), text)
         item.setFlags(Qt.ItemIsEnabled)
         table.setItem(row, 0, item)
         item = QTableWidgetItem()
         item.setText(action.shortcut().toString())
         item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable)
         item.oldShortcutText = item.text()
         table.setItem(row, 1, item)
     table.resizeColumnsToContents()
     self.connect(table, Signals.cellChanged, self.validateAction)
Пример #44
0
    def add_table(self, rows, columns, name, data):
        table = QTableWidget()
        table.setRowCount(rows)
        table.setColumnCount(columns)

        for k, v in list(data.items()):
            item = QTableWidgetItem()
            item.setText(v)
            if k[0] == 0:
                table.setHorizontalHeaderItem(k[1], item)
            else:
                table.setItem(k[0] - 1, k[1], item)
        #ntuples = " [ " + str(rows) + " ]"
        #item_list = QListWidgetItem(name + ntuples)
        #item_list.setTextAlignment(Qt.AlignHCenter)
        #self._list_tables.addItem(item_list)
        self.stacked.addWidget(table)
        self.stacked.setCurrentIndex(self.stacked.count() - 1)
Пример #45
0
def addSettingsToRow(settings, out_table):
    s = settings
    row = out_table.rowCount()
    out_table.insertRow(row)
    s = settings
    # insert values
    for i, value in enumerate([
            s.layerName, s.startTimeAttribute, s.endTimeAttribute, s.isEnabled,
            s.layerId, s.timeFormat,
            str(s.offset), s.interpolationEnabled, s.idAttribute,
            s.interpolationMode, not s.geometriesCount, s.accumulate
    ]):
        item = QTableWidgetItem()
        if type(value) != bool:
            item.setText(value)
        else:
            item.setCheckState(Qt.Checked if value else Qt.Unchecked)
        out_table.setItem(row, i, item)
Пример #46
0
 def add_table_from_rdb_content(self, content):
     lateral = Pireal.get_service("lateral")
     lateral.show()
     for line in content.splitlines():
         if line.startswith('@'):
             table = Table()
             name = line.split(':')[0][1:]
             lateral.add_item_list([name])
             fields = line.split(':')[-1].split(',')[:-1]
             table.setColumnCount(len(fields))
             table.setHorizontalHeaderLabels(fields)
             self.stacked.addWidget(table)
         else:
             row = table.rowCount()
             for e, i in enumerate(line.split(',')):
                 item = QTableWidgetItem()
                 item.setText(i)
                 table.setItem(row - 1, e, item)
             table.insertRow(row)
Пример #47
0
    def populate_function_table_1(self):
        """Populate the tblFunctions1 table with available functions."""
        hazards = deepcopy(hazard_all)
        exposures = exposure_all

        self.lblAvailableFunctions1.clear()
        self.tblFunctions1.clear()
        self.tblFunctions1.setColumnCount(len(hazards))
        self.tblFunctions1.setRowCount(len(exposures))
        for i in range(len(hazards)):
            hazard = hazards[i]
            item = QTableWidgetItem()
            item.setIcon(QIcon(get_image_path(hazard)))
            item.setText(hazard['name'].capitalize())
            item.setTextAlignment(Qt.AlignLeft)
            self.tblFunctions1.setHorizontalHeaderItem(i, item)
        for i in range(len(exposures)):
            exposure = exposures[i]
            item = QTableWidgetItem()
            item.setIcon(QIcon(get_image_path(exposure)))
            item.setText(exposure['name'].capitalize())
            self.tblFunctions1.setVerticalHeaderItem(i, item)
        developer_mode = setting('developer_mode', False, bool)
        for hazard in hazards:
            for exposure in exposures:
                item = QTableWidgetItem()
                if (exposure in hazard['disabled_exposures']
                        and not developer_mode):
                    background_colour = unavailable_option_color
                    # Set it disable and un-selectable
                    item.setFlags(item.flags() & ~Qt.ItemIsEnabled
                                  & ~Qt.ItemIsSelectable)
                else:
                    background_colour = available_option_color
                item.setBackground(QBrush(background_colour))
                item.setFont(big_font)
                item.setTextAlignment(Qt.AlignCenter | Qt.AlignHCenter)
                item.setData(RoleHazard, hazard)
                item.setData(RoleExposure, exposure)
                self.tblFunctions1.setItem(exposures.index(exposure),
                                           hazards.index(hazard), item)
        self.parent.pbnNext.setEnabled(False)
Пример #48
0
    def __fill_table(self):
        table = self.main_form.table

        lat_dict_to_show = self.grid_painter.grid.lat_dict_to_show

        table_data = []
        for phi, points in sorted(lat_dict_to_show.items(),
                                  key=lambda p: p[0]):
            for lam, x, y in points:
                table_data.append([
                    ts.dms_str(phi),
                    ts.dms_str(lam), '{: .3f}'.format(x), '{: .3f}'.format(y)
                ])

        table.setRowCount(len(table_data))
        for i, row in enumerate(table_data):
            for j, value in enumerate(row):
                item = QTableWidgetItem()
                item.setText(value)
                table.setItem(i, j, item)
Пример #49
0
    def populateDefPolTable(self):
        # add data to defpol table and format it
        self.g_defpol.clear()
        self.g_defpol.setAlternatingRowColors(True)
        self.g_defpol.setSortingEnabled(False)
        self.g_defpol.setHorizontalHeaderLabels(["Value", "Type"])
        self.g_defpol.setRowCount(
            len(self.config.defpol_index[self.config.lenOrgDefPol:]))

        for i, it in enumerate(
                self.config.defpol_index[self.config.lenOrgDefPol:]):
            item = QTableWidgetItem()
            item.setText(it)
            self.g_defpol.setItem(i, 0, item)
            item2 = QTableWidgetItem()
            item2.setText(self.config.defpol[it])
            item2.setTextAlignment(Qt.AlignCenter | Qt.AlignVCenter)
            self.g_defpol.setItem(i, 1, item2)

        self.g_defpol.resizeColumnsToContents()
Пример #50
0
    def clear(self):
        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
        self.output_text.clear()
        self.tableWidget.clear()

        self._currentTaskName = None
        self._currentTaskProgressBar = None
        self._currentTaskIncidents = None
        self._currentTaskIncidentsWidget = None
        self._currentTaskMessages = 0

        # Set up tablewidget
        self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableWidget.setRowCount(0)
        self.tableWidget.setColumnCount(3)
        item = QTableWidgetItem()
        item.setText('Rule')
        self.tableWidget.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        item.setText('Progress')
        self.tableWidget.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        item.setText('Incidents')
        self.tableWidget.setHorizontalHeaderItem(2, item)
        self.tableWidget.horizontalHeader().setResizeMode(QHeaderView.Stretch)
Пример #51
0
    def clear(self):
        self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
        self.output_text.clear()
        self.tableWidget.clear()

        self._currentTaskName = None
        self._currentTaskProgressBar = None
        self._currentTaskIncidents = None
        self._currentTaskIncidentsWidget = None
        self._currentTaskMessages = 0

        # Set up tablewidget
        self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableWidget.setRowCount(0);
        self.tableWidget.setColumnCount(3)
        item = QTableWidgetItem()
        item.setText('Rule')
        self.tableWidget.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        item.setText('Progress')
        self.tableWidget.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        item.setText('Incidents')
        self.tableWidget.setHorizontalHeaderItem(2, item)
        self.tableWidget.horizontalHeader().setResizeMode(QHeaderView.Stretch)
Пример #52
0
 def _update_joins(self, mi):
     combo = self.IDB.sender()
     row, col, new_col = combo.itemData(self.temp_col.index(mi))
     print(row, col, new_col)
     first_row = self.IDB.TWFinalExample.cellWidget(1, row).currentText()
     sub_colum_id = self.temp_col.index(first_row)
     sub_new_name = new_col
     old_row = row
     current_data = []
     errors_found = []
     for i in range(3, 13):
         try:
             current_data.append(
                 int(self.IDB.TWFinalExample.item(i, old_row).text()))
         except ValueError:
             errors_found.append(i)
             pass
     if len(current_data) == 0:
         print('no list')
     data = self.cursor.execute(
         "select * from {tbl}".format(tbl=self.other_tbls[int(col)]))
     data1 = data.fetchall()
     matching_ids = []
     matching_values = []
     for row in data1:
         matching_ids.append(row[sub_colum_id])
         matching_values.append(row[sub_new_name])
     j = -1
     for i in range(3, 13):
         if i in errors_found:
             continue
         j += 1
         idx = current_data[j]
         item = QTableWidgetItem()
         new_name = matching_values[matching_ids.index(idx)]
         item.setText(str(new_name))
         self.IDB.TWFinalExample.setItem(i, old_row, item)
Пример #53
0
 def _selected_main(self, mi):
     tbl = mi.row()
     colums = self.db_dict[self.tbl_names[tbl]]['col']
     data_example = self.db_dict[self.tbl_names[tbl]]['data']
     self.IDB.TWFinalExample.setRowCount(len(data_example) + 3)
     self.IDB.TWFinalExample.setColumnCount(len(colums))
     self.IDB.TWFinalExample.setSelectionBehavior(
         QAbstractItemView.SelectRows)
     self.IDB.TWFinalExample.setHorizontalHeaderLabels(
         [str(x) for x in colums])
     other_tbls = self.tbl_names
     other_tbls.remove(self.tbl_names[tbl])
     for i in range(len(colums)):
         c_box = QComboBox()
         for j, tbl_name in enumerate(other_tbls):
             c_box.addItem(tbl_name, (i, j))
         c_box.currentIndexChanged[str].connect(self._change_2nd_row)
         self.IDB.TWFinalExample.setCellWidget(0, i, c_box)
     self.other_tbls = other_tbls
     for i, row in enumerate(data_example):
         for j, col in enumerate(row):
             item = QTableWidgetItem()
             item.setText(str(col))
             self.IDB.TWFinalExample.setItem(i + 3, j, item)
Пример #54
0
    def updataAccountsTableView(self, accounts):
        rowCount = len(accounts)
        self.ui.tWAccounts.setRowCount(rowCount)
        row = 0
        for _, account in accounts.items():
            item = QTableWidgetItem()
            item.setText(account['appleid'])
            self.ui.tWAccounts.setItem(row, 0, item)

            item = QTableWidgetItem()
            item.setText(account['passwd'])
            self.ui.tWAccounts.setItem(row, 1, item)

            item = QTableWidgetItem()
            item.setText(account['governmentid'])
            self.ui.tWAccounts.setItem(row, 2, item)

            item = QTableWidgetItem()
            item.setText(account['phonenumber'])
            self.ui.tWAccounts.setItem(row, 3, item)
            row += 1
Пример #55
0
 def reloadSwitchersTable(self):
     """
     Załadowanie stanów zwrotnic do tabeli ze zwrotnicami.
     :return: None
     """
     self.switchTable.setRowCount(0)
     row = 0
     for s in self.controller.switchersLst:
         self.switchTable.insertRow(row)
         btn = QPushButton(self.switchTable)
         btn.setText('.')
         btn.setMaximumWidth(30)
         btn.clicked.connect(functools.partial(self.changeSwitcher, s))
         self.switchTable.setCellWidget(row, 0, btn)
         item = QTableWidgetItem()
         item.setText(s.deviceNo.__str__())
         self.switchTable.setItem(row, 1, item)
         item2 = QTableWidgetItem()
         item2.setText(s.state.__str__())
         self.switchTable.setItem(row, 2, item2)
         item3 = QTableWidgetItem()
         item3.setText(s.zone)
         self.switchTable.setItem(row, 3, item3)
         row = row + 1
Пример #56
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        Utils.setupLogger(logger)

        self.ui = Ui_EnergyChange()
        self.ui.setupUi(self)
        self.ui.scoretable.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setWindowTitle('Energy Change!')

        # Blank out 24-7 with 3 lines on klystron complement table (it doesn't
        # exist!)
        item = QTableWidgetItem()
        item.setText('---')
        self.ui.klysCompTable.setItem(6, 3, item)

        self.ui.textBrowser.append('Energy Change Initialized. Pick a time.')

        # Button for restoring klystron complement as found in archiver;
        # want disabled initially as nothing has been loaded yet
        self.ui.restoreButton.setDisabled(True)

        Utils.setupCalendar(self.ui.calendarWidget, self.ui.timeEdit)

        # Instatiate python score class
        self.scoreObject = PyScore()

        greetingIdx = randint(0, len(Utils.greetings) - 1)
        self.ui.statusText.setText(Utils.greetings[greetingIdx])

        self.loadStyleSheet()

        self.setpoints = {}
        Utils.populateSetpoints(self.setpoints)

        self.keyLists = {}
        Utils.populateKeyLists(self.keyLists)

        self.scoreInfo = {
            "scoreStructs": [],
            "dateChosen": None,
            "timeChosen": None
        }

        self.scoreData = {}

        self.klystronComplement = {"desired": {}, "original": {}}

        self.mirrorStatus = {
            "needToChangeM1": False,
            "hardPositionNeeded": False,
            "softPositionNeeded": False,
            "needToChangeM3": False,
            "amoPositionNeeded": False,
            "sxrPositionNeeded": False
        }

        self.timestamp = {
            "requested": None,
            "archiveStart": None,
            "archiveStop": None,
            "changeStarted": None
        }

        # valsObtained is boolean representing whether user has obtained archive
        # data for selected time. Scoreproblem is a boolean representing if
        # there was a problem loading some BDES. progress keeps track of the
        # progress number (between 0 and 100)
        self.diagnostics = {
            "progress": 0,
            "valsObtained": False,
            "scoreProblem": False,
            "threads": []
        }

        # Set progress bar to zero on GUI opening
        self.ui.progbar.setValue(0)

        # Get list of recent configs and populate GUI score table
        self.getScores()
        self.makeConnections()
Пример #57
0
    def _setup_available_indicators(self):
        indicator_nodes = get_available_indicator_nodes(self.project)

        current_row = self.indicator_table.currentRow()

        self.indicator_table.clear()
        self.indicator_table.setColumnCount(3)
        self.indicator_table.setRowCount(len(indicator_nodes))

        col = QTableWidgetItem()
        col.setText('Name')
        self.indicator_table.setHorizontalHeaderItem(0, col)

        col = QTableWidgetItem()
        col.setText('Dataset')
        self.indicator_table.setHorizontalHeaderItem(1, col)

        col = QTableWidgetItem()
        col.setText('Definition')
        self.indicator_table.setHorizontalHeaderItem(2, col)

        for i, indicator in enumerate(indicator_nodes):
            row = QTableWidgetItem()
            self.indicator_table.setVerticalHeaderItem(i, row)

            dataset, name = get_variable_dataset_and_name(indicator)

            item = QTableWidgetItem()
            item.setText(name)
            self.indicator_table.setItem(i, 0, item)

            item = QTableWidgetItem()
            item.setText(dataset)
            self.indicator_table.setItem(i, 1, item)

            item = QTableWidgetItem()
            item.setText(indicator.text or '')
            self.indicator_table.setItem(i, 2, item)

        if current_row is None or current_row == -1:
            current_row = 0
        self.indicator_table.resizeRowsToContents()
        self.indicator_table.resizeColumnsToContents()

        self.indicator_table.setCurrentCell(current_row, 0)
        self.on_indicator_table_itemSelectionChanged()