Python PyQt5.QtWidgets.QTableWidgetItem() Examples

The following are 30 code examples of PyQt5.QtWidgets.QTableWidgetItem(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .
Example #1
Source File: pkconfig.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
def load_tab_data(self, refresh=False):
        namespace = self.manifest.list.currentItem().data(NAMESPACE_ROLE)
        data = self.pkmeter.data.get(namespace, {})
        data = utils.flatten_datatree(data, namespace)
        if not data:
            return self.load_message('Data not available for this module.')
        self.datatable.setRowCount(len(data))
        for row in range(len(data)):
            for col in range(3):
                item = QtWidgets.QTableWidgetItem(data[row][col], 0)
                self.datatable.setItem(row, col, item)
        if not refresh:
            self.datatable_wrap.manifest.filter.setText('')
        else:
            self.filter_datatable()
        self.datatable_wrap.setParent(self.manifest.contents)
        self.manifest.contents.layout().addWidget(self.datatable_wrap) 
Example #2
Source File: AnalysisWidget.py    From idasec with GNU Lesser General Public License v2.1 7 votes vote down vote up
def add_input_action(self):
        self.inputs_table.setRowCount(self.inputs_table.rowCount()+1)
        i = self.inputs_table.rowCount()-1
        type_combo = QtWidgets.QComboBox()
        type_combo.addItems(["REG", "MEM"])
        action_combo = QtWidgets.QComboBox()
        action_combo.addItems(["DEFAULT", "PATCH", "CONC", "SYMB", "IGNORE"])
        when_combo = QtWidgets.QComboBox()
        when_combo.addItems(["BEFORE", "AFTER"])
        info = [type_combo, QtWidgets.QTableWidgetItem(), QtWidgets.QTableWidgetItem(), QtWidgets.QTableWidgetItem(),
                action_combo, when_combo]

        for col_id, widget in enumerate(info):
            if isinstance(widget, QtWidgets.QTableWidgetItem):
                self.inputs_table.setItem(i, col_id, widget)
            else:
                self.inputs_table.setCellWidget(i, col_id, widget)
        return i 
Example #3
Source File: main.py    From PyQt5-Apps with GNU General Public License v3.0 7 votes vote down vote up
def updateTable(self, w):
        """:author : Tich
        update data in the table
        :param w: update data in `w.table`
        """
        try:
            num = cursor.execute("SELECT * FROM words ORDER BY origin;")
            if num:
                w.table.setRowCount(num)
                for r in cursor:
                    # print(r)
                    i = cursor.rownumber - 1
                    for x in range(3):
                        item = QTableWidgetItem(str(r[x]))
                        item.setTextAlignment(Qt.AlignCenter);
                        w.table.setItem(i, x, item)
        except Exception as e:
            # print(e)
            self.messageBox("update table error!\nerror msg: %s"%e.args[1]) 
Example #4
Source File: lab5.py    From Computer-graphics with MIT License 6 votes vote down vote up
def add_point(point):
    global w
    if w.point_now is None:
        w.point_now = point
        w.point_lock = point
        add_row(w)
        i = w.table.rowCount() - 1
        item_x = QTableWidgetItem("{0}".format(point.x()))
        item_y = QTableWidgetItem("{0}".format(point.y()))
        w.table.setItem(i, 0, item_x)
        w.table.setItem(i, 1, item_y)
    else:
        w.edges.append([w.point_now.x(), w.point_now.y(),
                        point.x(), point.y()])
        w.point_now = point
        add_row(w)
        i = w.table.rowCount() - 1
        item_x = QTableWidgetItem("{0}".format(point.x()))
        item_y = QTableWidgetItem("{0}".format(point.y()))
        w.table.setItem(i, 0, item_x)
        w.table.setItem(i, 1, item_y)
        item_x = w.table.item(i-1, 0)
        item_y = w.table.item(i-1, 1)
        w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen)
    #print(w.edges) 
Example #5
Source File: archive_tab.py    From restatic with GNU General Public License v3.0 6 votes vote down vote up
def populate_from_profile(self):

        profile = self.profile()

        if profile.repo is not None:
            self.currentRepoLabel.setText(profile.repo.url)
            self.archiveTable.setRowCount(0)  # clear the table

            for row, archive in enumerate(
                ArchiveModel.select().where(ArchiveModel.repo == profile.repo)
            ):
                self.archiveTable.insertRow(row)
                formatted_time = str(archive.time)
                # formatted_time = archive.time.strftime("%Y-%m-%d %H:%M") # FIXME
                self.archiveTable.setItem(row, 0, QTableWidgetItem(archive.name))
                self.archiveTable.setItem(row, 1, QTableWidgetItem(formatted_time))
                self.archiveTable.setItem(row, 2, QTableWidgetItem(archive.hostname))
            # self.archiveTable.setRowCount(len(archives))
            self._toggle_all_buttons(enabled=True)

        else:
            self.archiveTable.setRowCount(0)
            self.currentRepoLabel.setText("N/A")
            self._toggle_all_buttons(enabled=False) 
Example #6
Source File: UI_databank.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def rellenar(self):
        """Fill in list with component from database"""
        self.BaseDatos.setRowCount(0)
        sql.databank.execute("select * from compuestos")
        for i in sql.databank:
            self.BaseDatos.setRowCount(self.BaseDatos.rowCount()+1)
            self.BaseDatos.setItem(
                i[0]-1, 0, QtWidgets.QTableWidgetItem(str(i[0])))
            self.BaseDatos.setItem(i[0]-1, 1, QtWidgets.QTableWidgetItem(i[2]))
            self.BaseDatos.setItem(i[0]-1, 2, QtWidgets.QTableWidgetItem(i[1]))
            self.BaseDatos.setRowHeight(self.BaseDatos.rowCount()-1, 20)

        sql.databank_Custom.execute("select * from compuestos")
        for i in sql.databank_Custom:
            filas = self.BaseDatos.rowCount()
            self.BaseDatos.setRowCount(filas+1)
            self.BaseDatos.setItem(
                filas, 0, QtWidgets.QTableWidgetItem(str(i[0])))
            self.BaseDatos.setItem(filas, 1, QtWidgets.QTableWidgetItem(i[2]))
            self.BaseDatos.setItem(filas, 2, QtWidgets.QTableWidgetItem(i[1]))
            self.BaseDatos.setRowHeight(self.BaseDatos.rowCount()-1, 20)

        self.BaseDatos.resizeColumnsToContents() 
Example #7
Source File: schedule_tab.py    From vorta with GNU General Public License v3.0 6 votes vote down vote up
def init_logs(self):
        self.logTableWidget.setAlternatingRowColors(True)
        header = self.logTableWidget.horizontalHeader()
        header.setVisible(True)
        [header.setSectionResizeMode(i, QHeaderView.ResizeToContents) for i in range(5)]
        header.setSectionResizeMode(3, QHeaderView.Stretch)

        self.logTableWidget.setSelectionBehavior(QTableView.SelectRows)
        self.logTableWidget.setEditTriggers(QTableView.NoEditTriggers)

        event_logs = [s for s in EventLogModel.select().order_by(EventLogModel.start_time.desc())]

        for row, log_line in enumerate(event_logs):
            self.logTableWidget.insertRow(row)
            formatted_time = log_line.start_time.strftime('%Y-%m-%d %H:%M')
            self.logTableWidget.setItem(row, 0, QTableWidgetItem(formatted_time))
            self.logTableWidget.setItem(row, 1, QTableWidgetItem(log_line.category))
            self.logTableWidget.setItem(row, 2, QTableWidgetItem(log_line.subcommand))
            self.logTableWidget.setItem(row, 3, QTableWidgetItem(log_line.repo_url))
            self.logTableWidget.setItem(row, 4, QTableWidgetItem(str(log_line.returncode)))
        self.logTableWidget.setRowCount(len(event_logs))
        self._draw_next_scheduled_backup() 
Example #8
Source File: lab6.py    From Computer-graphics with MIT License 6 votes vote down vote up
def add_point(point):
    global w
    if w.point_now is None:
        w.point_now = point
        w.point_lock = point
        add_row(w)
        i = w.table.rowCount() - 1
        item_x = QTableWidgetItem("{0}".format(point.x()))
        item_y = QTableWidgetItem("{0}".format(point.y()))
        w.table.setItem(i, 0, item_x)
        w.table.setItem(i, 1, item_y)
    else:
        w.edges.append([w.point_now.x(), w.point_now.y(),
                        point.x(), point.y()])
        w.point_now = point
        add_row(w)
        i = w.table.rowCount() - 1
        item_x = QTableWidgetItem("{0}".format(point.x()))
        item_y = QTableWidgetItem("{0}".format(point.y()))
        w.table.setItem(i, 0, item_x)
        w.table.setItem(i, 1, item_y)
        item_x = w.table.item(i-1, 0)
        item_y = w.table.item(i-1, 1)
        w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen)
    #print(w.edges) 
Example #9
Source File: sparrowdialogs.py    From sparrow-wifi with GNU General Public License v3.0 6 votes vote down vote up
def onAgentAnnounce(self, ipAddr, port):
        if not self.agentInTable(ipAddr, port):
            rowPosition = self.agentTable.rowCount()
            rowPosition -= 1
            addedFirstRow = False
            if rowPosition < 0:
                addedFirstRow = True
                rowPosition = 0
                
            self.agentTable.insertRow(rowPosition)
            
            # Just make sure we don't get an extra blank row
            if (addedFirstRow):
                self.agentTable.setRowCount(1)

            self.agentTable.setItem(rowPosition, 0, QTableWidgetItem(ipAddr))
            self.agentTable.setItem(rowPosition, 1, IntTableWidgetItem(str(port)))
            self.agentTable.resizeColumnsToContents()
            self.agentTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) 
Example #10
Source File: main_gui.py    From simnibs with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        #self.position_struc = sim_struct.POSITION()
        self.p1 = []
        self.p2 = []
        #self.ogl_object = None
        #self.electrode.definition = 'plane'
        self.didt_box = QtWidgets.QDoubleSpinBox()
        self.didt_box.setSuffix("x10e6 A/s")
        self.didt_box.setMinimum(0)
        self.didt_box.setMaximum(200)
        self.didt_box.setSingleStep(0.5)
        self.didt_box.setValue(1)

        self.dist_box = QtWidgets.QDoubleSpinBox()
        self.dist_box.setSuffix("mm")
        self.dist_box.setMinimum(0.)
        self.dist_box.setMaximum(200)
        self.dist_box.setSingleStep(1)
        self.dist_box.setValue(4)

        self.position_item = QtWidgets.QTableWidgetItem('')
        self.position_item.setFlags(self.position_item.flags() ^ QtCore.Qt.ItemIsEditable)

        self.name_item = QtWidgets.QTableWidgetItem('') 
Example #11
Source File: lab7.py    From Computer-graphics with MIT License 6 votes vote down vote up
def add_point(point):
    global w
    if w.input_bars:
        if w.point_now is None:
            w.point_now = point
        else:
            w.lines.append([[w.point_now.x(), w.point_now.y()],
                            [point.x(), point.y()]])

            add_row(w)
            i = w.table.rowCount() - 1
            item_b = QTableWidgetItem("[{0}, {1}]".format(w.point_now.x(), w.point_now.y()))
            item_e = QTableWidgetItem("[{0}, {1}]".format(point.x(), point.y()))
            w.table.setItem(i, 0, item_b)
            w.table.setItem(i, 1, item_e)
            w.scene.addLine(w.point_now.x(), w.point_now.y(), point.x(), point.y(), w.pen)
            w.point_now = None 
Example #12
Source File: locationbrowser.py    From PyPipboyApp with GNU General Public License v3.0 6 votes vote down vote up
def showLocationProperties(self, location):
        if location:
            props = location.value()
            self.widget.propertyTable.setRowCount(len(props))
            keys = list(props.keys())
            keys.sort()
            r = 0
            for k in keys:
                prop = props[k]
                nameItem = QtWidgets.QTableWidgetItem(prop.pipParentKey)
                if k in ['locationformid', 'locationmarkerformid']:
                    value = hex(prop.value())
                else:
                    value = str(prop.value())
                valueItem = QtWidgets.QTableWidgetItem(value)
                self.widget.propertyTable.setItem(r, 0, nameItem)
                self.widget.propertyTable.setItem(r, 1, valueItem)
                r += 1 
Example #13
Source File: lab8.py    From Computer-graphics with MIT License 6 votes vote down vote up
def add_bars(win):
    if len(win.edges) == 0:
        QMessageBox.warning(win, "Внимание!", "Не введен отсекатель!")
        return
    win.pen.setColor(red)
    w.lines.append([[win.edges[0].x() - 15, win.edges[0].y() - 15],
                    [win.edges[1].x() - 15, win.edges[1].y() - 15]])
    add_row(w.table_bars)
    i = w.table_bars.rowCount() - 1
    item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() - 15 , win.edges[0].y() - 15))
    item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() - 15, win.edges[1].y() - 15))
    w.table_bars.setItem(i, 0, item_b)
    w.table_bars.setItem(i, 1, item_e)
    w.scene.addLine(win.edges[0].x() - 15, win.edges[0].y() - 15, win.edges[1].x() - 15, win.edges[1].y() - 15, w.pen)

    win.pen.setColor(red)
    w.lines.append([[win.edges[0].x() + 15, win.edges[0].y() + 15],
                    [win.edges[1].x() + 15, win.edges[1].y() + 15]])
    add_row(w.table_bars)
    i = w.table_bars.rowCount() - 1
    item_b = QTableWidgetItem("[{0}, {1}]".format(win.edges[0].x() + 15, win.edges[0].y() + 15))
    item_e = QTableWidgetItem("[{0}, {1}]".format(win.edges[1].x() + 15, win.edges[1].y() + 15))
    w.table_bars.setItem(i, 0, item_b)
    w.table_bars.setItem(i, 1, item_e)
    w.scene.addLine(win.edges[0].x() + 15, win.edges[0].y() + 15, win.edges[1].x() + 15, win.edges[1].y() + 15, w.pen) 
Example #14
Source File: newComponent.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def add(self):
        """Add the current selected item to the list of group"""
        indice = self.Group.rowCount()
        grupo = self.groupContributions.currentItem().text()
        if grupo not in self.grupo:
            self.grupo.append(grupo)
            self.indices.append(self.groupContributions.currentRow())
            self.contribucion.append(1)
            self.Group.setRowCount(indice+1)
            self.Group.setItem(indice, 0, QtWidgets.QTableWidgetItem("1"))
            self.Group.item(indice, 0).setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.Group.setItem(indice, 1, QtWidgets.QTableWidgetItem(grupo))
            self.Group.item(indice, 1).setFlags(
                QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
            self.Group.setRowHeight(indice, 20)
        else:
            indice = self.grupo.index(grupo)
            self.contribucion[indice] += 1
            self.Group.item(indice, 0).setText(str(int(
                self.Group.item(indice, 0).text())+1))
        kw = {"group": self.indices, "contribution": self.contribucion}
        self.calculo(**kw) 
Example #15
Source File: UI_pipe.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def CodoSegmentado(self):
        title = QtWidgets.QApplication.translate("pychemqt", "Mitre bend with custom angle")
        icon = os.environ["pychemqt"]+"/images/equip/MB45.png"
        parameter = [QtWidgets.QApplication.translate("pychemqt", "Pipe diameter"), ""]
        dialog = Dialog(1, title, icon, parameter)
        if dialog.exec_():
            indice = self.Accesorios.rowCount()
            self.Accesorios.setRowCount(indice+1)
            self.Accesorios.setItem(indice, 0, QtWidgets.QTableWidgetItem(
                QtGui.QIcon(QtGui.QPixmap(icon)), "MBx"))
            self.Accesorios.setItem(indice, 1, QtWidgets.QTableWidgetItem(
                "%0.3f" % dialog.D1.value.mm))
            self.Accesorios.setItem(indice, 2, QtWidgets.QTableWidgetItem(
                "θ=%iº" % dialog.angulo.value()))
            self.Accesorios.setItem(indice, 3, QtWidgets.QTableWidgetItem(
                representacion(dialog.K, 3)))
            self.Accesorios.item(indice, 3).setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.Accesorios.setItem(indice, 4, QtWidgets.QTableWidgetItem(str(1)))
            self.Accesorios.item(indice, 4).setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.Accesorios.setItem(indice, 5, QtWidgets.QTableWidgetItem(
                QtWidgets.QApplication.translate("pychemqt", "Mitre Bend")))
            self.Accesorios.setRowHeight(indice, 20)
            self.CalcularK() 
Example #16
Source File: UI_pipe.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def CodoLargo(self):
        title = QtWidgets.QApplication.translate("pychemqt", "Long Pipe Bend")
        icon = os.environ["pychemqt"]+"/images/equip/LB.png"
        parameter = [
            QtWidgets.QApplication.translate("pychemqt", "Bend radio"),
            QtWidgets.QApplication.translate("pychemqt", "Pipe diameter")]
        dialog = Dialog(2, title, icon, parameter)
        if dialog.exec_():
            indice = self.Accesorios.rowCount()
            self.Accesorios.setRowCount(indice+1)
            self.Accesorios.setItem(indice, 0, QtWidgets.QTableWidgetItem(
                QtGui.QIcon(QtGui.QPixmap(icon)), "LB"))
            self.Accesorios.setSpan(indice, 1, 1, 2)
            self.Accesorios.setItem(indice, 1, QtWidgets.QTableWidgetItem(
                "r=%0.3f, D=%0.3f" % (dialog.D1.value.mm, dialog.D2.value.mm)))
            self.Accesorios.setItem(indice, 3, QtWidgets.QTableWidgetItem(
                representacion(dialog.K, 3)))
            self.Accesorios.item(indice, 3).setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.Accesorios.setItem(indice, 4, QtWidgets.QTableWidgetItem(str(1)))
            self.Accesorios.item(indice, 4).setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            self.Accesorios.setItem(indice, 5, QtWidgets.QTableWidgetItem(title))
            self.Accesorios.setRowHeight(indice, 20)
            self.CalcularK() 
Example #17
Source File: magic.py    From heap-viewer with GNU General Public License v3.0 6 votes vote down vote up
def find_fakefast_on_click(self):
        start_addr = int(self.t_fakefast_addr.text(), 16)
        fake_chunks = self.heap.find_fakefast(start_addr)

        if len(fake_chunks) == 0:
            idaapi.info("Fakefast: 0 results")
            return

        self.tbl_fakefast.clearContents()
        self.tbl_fakefast.setRowCount(0)
        self.tbl_fakefast.setSortingEnabled(False)

        for idx, chunk in enumerate(fake_chunks):
            self.tbl_fakefast.insertRow(idx)
            self.tbl_fakefast.setItem(idx, 0, QtWidgets.QTableWidgetItem("%d" % chunk['fast_id']))
            self.tbl_fakefast.setItem(idx, 1, QtWidgets.QTableWidgetItem("0x%x" % chunk['size']))
            self.tbl_fakefast.setItem(idx, 2, QtWidgets.QTableWidgetItem("%d" % chunk['bytes_to']))
            self.tbl_fakefast.setItem(idx, 3, QtWidgets.QTableWidgetItem("0x%x" % chunk['address']))    

        self.tbl_fakefast.resizeRowsToContents()
        self.tbl_fakefast.resizeColumnsToContents()
        self.tbl_fakefast.setSortingEnabled(True)


# ----------------------------------------------------------------------- 
Example #18
Source File: main.py    From PyQt5-Apps with GNU General Public License v3.0 6 votes vote down vote up
def updateItem(self, t, array):
        """update downloadWidget cell
        t: qthread
        array: (val1, [val2], flag)
        val1: contains (downloaded count)/(total count)*100 / cur_slice
        val2: total slices
        op:0 => download counts
            :1 => video slices
        """
        val = array[0]
        op = array[-1]
        for k, v in self.row2qthread.items():
            if v == t:
                if op==0:
                    self.downloadWidget.cellWidget(k, 3).setValue(val)
                else:
                    item = QTableWidgetItem('{}/{}'.format(val, array[-2]))
                    self.downloadWidget.setItem(k, 2, item)
                return 
Example #19
Source File: main.py    From PyQt5-Apps with GNU General Public License v3.0 6 votes vote down vote up
def downloaded(self, t, slices):
        """finish a video downloading
        """
        print('downloaded')
        for k, v in self.row2qthread.items():
            if v == t:
                if slices == -1:
                    s = '下载出错:'+ self.downloadWidget.item(k, 0).text()
                    item = QTableWidgetItem(s)
                    self.downloadWidget.setItem(k, 0, item)
                elif slices == -2:
                    s = '结束下载:'+ self.downloadWidget.item(k, 0).text()
                    item = QTableWidgetItem(s)
                    self.downloadWidget.setItem(k, 0, item)
                else:
                    item = QTableWidgetItem('{0}/{0}'.format(slices))
                    self.downloadWidget.setItem(k, 2, item)
                    QMessageBox.about(self, '哔哩哔哩工具箱 v1.1 - ©Tich', '{} 下载完成!'.format(self.downloadWidget.item(k, 0).text()))
                break 
Example #20
Source File: main.py    From PyQt5-Apps with GNU General Public License v3.0 6 votes vote down vote up
def singleDownload(self):
        print('single')
        row = self.downloadWidget.rowCount()
        self.downloadWidget.setRowCount(row+1)
        item = QTableWidgetItem(self.title)
        self.downloadWidget.setItem(row, 0, item)
        item = QTableWidgetItem('p{}'.format(self.page))
        self.downloadWidget.setItem(row, 1, item)
        item = QTableWidgetItem('0/{}'.format(self.slices))
        self.downloadWidget.setItem(row, 2, item)
        qpb = QProgressBar()
        qpb.setValue(0)
        self.downloadWidget.setCellWidget(row, 3, qpb)
        # print(self.links)
        t = Downloader(self.av, self.links)
        self.row2qthread[row] = t
        t.finish.connect(self.downloaded)
        t.signal.connect(self.updateItem)
        t.cur_slice.connect(self.updateItem)
        t.start()
        # print(int(t.currentThreadId())) 
Example #21
Source File: widgets.py    From pychemqt with GNU General Public License v3.0 5 votes vote down vote up
def addRow(self, data=None, index=None):
        """Add row to widget
        data: Array with data to fill new row
        index: Index to add row, default add row at endo of table"""
        if not data:
            data = [""]*self.columnas
        else:
            data = [representacion(i) for i in data]
        if index is not None:
            row = index
        else:
            row = self.rowCount()
        self.insertRow(row)
        self.setRowHeight(row, 22)

        if self.delegateforRow:
            delegate = self.delegateforRow(self.parent())
            self.setItemDelegateForRow(row, delegate)

        Config = ConfigParser()
        Config.read(conf_dir+"pychemqtrc")
        inactivo = QtGui.QColor(Config.get("General", 'Color_ReadOnly'))
        for j in range(self.columnCount()):
            self.setItem(row, j, QtWidgets.QTableWidgetItem(data[j]))
            self.item(row, j).setTextAlignment(
                self.orientacion | QtCore.Qt.AlignVCenter)

            if self.columnReadOnly[j]:
                flags = QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
                self.item(row, j).setBackground(inactivo)
            else:
                flags = QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | \
                    QtCore.Qt.ItemIsSelectable
            self.item(row, j).setFlags(flags)

        self.setVHeader(row)

        # Set focus to first editable cell in new row
        if self.dinamica and self.rowCount() > 1:
            columna = self.columnReadOnly.index(False)
            self.setCurrentCell(row, columna) 
Example #22
Source File: reg_table_widget.py    From execution-trace-viewer with MIT License 5 votes vote down vote up
def update(self):
        """Fills table with registers"""
        if self.rowCount() != len(self.regs):
            self.setRowCount(len(self.regs))
        if not self.regs:
            return

        i = 0
        for reg, value in self.regs.items():
            if self.filtered_regs and reg not in self.filtered_regs:
                continue
            self.setItem(i, 0, QTableWidgetItem(reg))
            if isinstance(value, int):
                self.setItem(i, 1, QTableWidgetItem(hex(value)))
                self.setItem(i, 2, QTableWidgetItem(str(value)))
            else:
                self.setItem(i, 1, QTableWidgetItem(value))
            if reg in self.modified_regs:
                self.item(i, 0).setBackground(QColor(100, 100, 150))
                self.item(i, 1).setBackground(QColor(100, 100, 150))
                self.item(i, 2).setBackground(QColor(100, 100, 150))
            i += 1

        if "eflags" in self.regs:
            eflags = self.regs["eflags"]
            flags = {
                "c": eflags & 1,           # carry
                "p": (eflags >> 2) & 1,    # parity
                # "a": (eflags >> 4) & 1,  # aux_carry
                "z": (eflags >> 6) & 1,    # zero
                "s": (eflags >> 7) & 1,    # sign
                # "d": (eflags >> 10) & 1, # direction
                # "o":  (eflags >> 11) & 1 # overflow
            }
            flags_text = f"C:{flags['c']} P:{flags['p']} Z:{flags['z']} S:{flags['s']}"
            self.setRowCount(i + 1)
            self.setItem(i, 0, QTableWidgetItem("flags"))
            self.setItem(i, 1, QTableWidgetItem(flags_text)) 
Example #23
Source File: bins.py    From heap-viewer with GNU General Public License v3.0 5 votes vote down vote up
def populate_table(self):
        self.tbl_tcache.clearContents()
        self.tbl_tcache.setRowCount(0)
        self.tbl_tcache.setSortingEnabled(False)

        tcache = self.heap.get_tcache(self.cur_arena)

        if not tcache:
            return

        idx = 0
        for i, (size, entry) in enumerate(tcache.items()):

            if entry['counts'] == 0 and entry['next'] == 0:
                continue

            self.tbl_tcache.insertRow(idx)

            it_entry_id  = QtWidgets.QTableWidgetItem("%d" % i)
            it_size  = QtWidgets.QTableWidgetItem("%#x" % size)
            it_counts = QtWidgets.QTableWidgetItem("%d" % entry['counts'])
            it_address = QtWidgets.QTableWidgetItem("%#x" % entry['next'])

            self.tbl_tcache.setItem(idx, 0, it_entry_id)
            self.tbl_tcache.setItem(idx, 1, it_size)
            self.tbl_tcache.setItem(idx, 2, it_counts)
            self.tbl_tcache.setItem(idx, 3, it_address)

            idx += 1

        self.tbl_tcache.resizeRowsToContents()
        self.tbl_tcache.resizeColumnsToContents()
        self.tbl_tcache.setSortingEnabled(True) 
Example #24
Source File: bins.py    From heap-viewer with GNU General Public License v3.0 5 votes vote down vote up
def populate_tbl_largebins(self):
        self.tbl_largebins.clearContents()
        self.tbl_largebins.setRowCount(0)
        self.tbl_largebins.setSortingEnabled(False)

        largebins = self.heap.get_largebins(self.cur_arena)

        idx = 0
        for bin_id, largebin in largebins.items():

            # point to himself
            if not self.show_bases and largebin['base'] == largebin['fd']:
                continue
  
            self.tbl_largebins.insertRow(idx)
            it_bin_num  = QtWidgets.QTableWidgetItem("%d" % bin_id)
            it_size = QtWidgets.QTableWidgetItem("%#x" % largebin['size'])
            it_fd = QtWidgets.QTableWidgetItem("%#x" % largebin['fd'])
            it_bk = QtWidgets.QTableWidgetItem("%#x" % largebin['bk'])
            it_base = QtWidgets.QTableWidgetItem("%#x" % largebin['base'])

            self.tbl_largebins.setItem(idx, 0, it_bin_num)
            self.tbl_largebins.setItem(idx, 1, it_size)
            self.tbl_largebins.setItem(idx, 2, it_fd)
            self.tbl_largebins.setItem(idx, 3, it_bk)
            self.tbl_largebins.setItem(idx, 4, it_base)

            idx += 1

        self.tbl_largebins.resizeRowsToContents()
        self.tbl_largebins.resizeColumnsToContents()
        self.tbl_largebins.setSortingEnabled(True) 
Example #25
Source File: bins.py    From heap-viewer with GNU General Public License v3.0 5 votes vote down vote up
def populate_tbl_smallbins(self):
        self.tbl_smallbins.clearContents()
        self.tbl_smallbins.setRowCount(0)
        self.tbl_smallbins.setSortingEnabled(False)

        smallbins = self.heap.get_smallbins(self.cur_arena)

        idx = 0
        for bin_id, smallbin in smallbins.items():

            # point to himself
            if not self.show_bases and smallbin['base'] == smallbin['fd']:
                continue

            self.tbl_smallbins.insertRow(idx)
            it_bin_num  = QtWidgets.QTableWidgetItem("%d" % bin_id)
            it_size = QtWidgets.QTableWidgetItem("%#x" % smallbin['size'])
            it_fd = QtWidgets.QTableWidgetItem("%#x" % smallbin['fd'])
            it_bk = QtWidgets.QTableWidgetItem("%#x" % smallbin['bk'])
            it_base = QtWidgets.QTableWidgetItem("%#x" % smallbin['base'])

            self.tbl_smallbins.setItem(idx, 0, it_bin_num)
            self.tbl_smallbins.setItem(idx, 1, it_size)
            self.tbl_smallbins.setItem(idx, 2, it_fd)
            self.tbl_smallbins.setItem(idx, 3, it_bk)
            self.tbl_smallbins.setItem(idx, 4, it_base)

            idx += 1

        self.tbl_smallbins.resizeRowsToContents()
        self.tbl_smallbins.resizeColumnsToContents()
        self.tbl_smallbins.setSortingEnabled(True) 
Example #26
Source File: bins.py    From heap-viewer with GNU General Public License v3.0 5 votes vote down vote up
def populate_tbl_unsortedbin(self):
        base, fd, bk = self.heap.get_unsortedbin(self.cur_arena)

        self.tbl_unsortedbin.clearContents()
        self.tbl_unsortedbin.setRowCount(0)

        # points to current base
        if not self.show_bases and fd == base:
            return

        self.tbl_unsortedbin.setSortingEnabled(False)
        self.tbl_unsortedbin.insertRow(0)

        it_bin_num  = QtWidgets.QTableWidgetItem("1")
        it_fd = QtWidgets.QTableWidgetItem("%#x" % fd)
        it_bk = QtWidgets.QTableWidgetItem("%#x" % bk)
        it_base = QtWidgets.QTableWidgetItem("%#x" % base)

        self.tbl_unsortedbin.setItem(0, 0, it_bin_num)
        self.tbl_unsortedbin.setItem(0, 1, it_fd)
        self.tbl_unsortedbin.setItem(0, 2, it_bk)
        self.tbl_unsortedbin.setItem(0, 3, it_base)

        self.tbl_unsortedbin.resizeRowsToContents()
        self.tbl_unsortedbin.resizeColumnsToContents()
        self.tbl_unsortedbin.setSortingEnabled(True) 
Example #27
Source File: bins.py    From heap-viewer with GNU General Public License v3.0 5 votes vote down vote up
def populate_tbl_fastbins(self): 
        self.tbl_fastbins.clearContents()
        self.tbl_fastbins.setRowCount(0)
        self.tbl_fastbins.setSortingEnabled(False)

        idx = 0
        fastbins = self.heap.get_fastbins(self.cur_arena)
        for id_fast, (size, fast_chunk) in enumerate(fastbins.items()):

            if not self.show_bases and fast_chunk == 0:
                continue

            self.tbl_fastbins.insertRow(idx)

            it_bin_num  = QtWidgets.QTableWidgetItem("%d" % id_fast)
            it_size = QtWidgets.QTableWidgetItem("%#x" % size)
            it_fastchunk = QtWidgets.QTableWidgetItem("%#x" % fast_chunk)

            self.tbl_fastbins.setItem(idx, 0, it_bin_num)
            self.tbl_fastbins.setItem(idx, 1, it_size)
            self.tbl_fastbins.setItem(idx, 2, it_fastchunk)

            idx += 1

        if idx:
            self.tbl_fastbins.resize_to_contents()
            self.tbl_fastbins.setSortingEnabled(True) 
Example #28
Source File: diff_dialog.py    From vorta with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, archiveTable):
        super().__init__()
        self.setupUi(self)

        header = self.archiveTable.horizontalHeader()
        header.setVisible(True)
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(3, QHeaderView.Interactive)
        header.setSectionResizeMode(4, QHeaderView.Stretch)
        header.setStretchLastSection(True)

        self.archiveTable.setSelectionBehavior(QTableView.SelectRows)
        self.archiveTable.setSelectionMode(QTableView.MultiSelection)
        self.archiveTable.setEditTriggers(QTableView.NoEditTriggers)
        self.archiveTable.setWordWrap(False)
        self.archiveTable.setTextElideMode(QtCore.Qt.ElideLeft)
        self.archiveTable.setAlternatingRowColors(True)
        self.archiveTable.itemSelectionChanged.connect(self.itemSelectionChanged_action)

        # Copy archiveTable of MainWindow
        self.archiveTable.setRowCount(archiveTable.rowCount())
        for row in range(archiveTable.rowCount()):
            for column in range(archiveTable.columnCount()):
                try:
                    text = archiveTable.item(row, column).text()
                    self.archiveTable.setItem(row, column, QTableWidgetItem(text))
                except AttributeError:
                    self.archiveTable.setItem(row, column, QTableWidgetItem(""))

        self.diffButton.setEnabled(False)

        self.cancelButton.clicked.connect(self.close)
        self.diffButton.clicked.connect(self.diff_action)
        self.selected_archives = None 
Example #29
Source File: table.py    From pychemqt with GNU General Public License v3.0 5 votes vote down vote up
def hHeaderClicked(self, event):
        """Show dialog to config format and unit"""
        col = self.horizontalHeader().logicalIndexAt(event)
        unit = self.units[col]
        dialog = NumericFactor(self.format[col], unit, self.orderUnit[col])
        if dialog.exec_():
            # Check unit change
            if unit != unidades.Dimensionless and \
                    dialog.unit.currentIndex() != self.orderUnit[col]:
                for i, fila in enumerate(self.data):
                    conf = unit.__units__[self.orderUnit[col]]
                    key = unit.__units__[dialog.unit.currentIndex()]
                    value = unit(fila[col], conf).__getattribute__(key)
                    self.data[i][col] = value
                self.orderUnit[col] = dialog.unit.currentIndex()
                txt = self.horizontalHeaderItem(
                    col).text().split(os.linesep)[0]
                txt += os.linesep+unit.__text__[dialog.unit.currentIndex()]
                self.setHorizontalHeaderItem(
                    col, QtWidgets.QTableWidgetItem(txt))

            # Check format change
            self.format[col] = dialog.args()
            self.setStr()
            self.resizeColumnToContents(col)
        range = QtWidgets.QTableWidgetSelectionRange(
            0, col, self.rowCount()-1, col)
        self.setRangeSelected(range, True) 
Example #30
Source File: sparrowdialogs.py    From sparrow-wifi with GNU General Public License v3.0 5 votes vote down vote up
def updateTable(self, curGPS):        
        if curGPS == self.lastGPS:
            # Don't update if nothing's changed and we're not on our first iteration
            return
        
        self.lastGPS = curGPS  # Set for the next pass
        
        rowCount = self.historyTable.rowCount()
        rowCount -= 1
        addedFirstRow = False
        if rowCount < 0:
            addedFirstRow = True
            rowCount = 0
            
        # Insert new at the top
        self.historyTable.insertRow(0)

        # Just make sure we don't get an extra blank row
        if (addedFirstRow):
            self.historyTable.setRowCount(1)

        rowPosition = 0 # Always at the first row
        self.historyTable.setItem(rowPosition, 0, DateTableWidgetItem(datetime.datetime.now().strftime("%m/%d/%Y %H:%M:%S")))
        if (curGPS.isValid):
            self.historyTable.setItem(rowPosition,1, QTableWidgetItem('Yes'))
        else:
            self.historyTable.setItem(rowPosition,1, QTableWidgetItem('No'))
            
        self.historyTable.setItem(rowPosition, 2, FloatTableWidgetItem(str(curGPS.latitude)))
        self.historyTable.setItem(rowPosition, 3, FloatTableWidgetItem(str(curGPS.longitude)))
        self.historyTable.setItem(rowPosition, 4, FloatTableWidgetItem(str(curGPS.altitude)))
        self.historyTable.setItem(rowPosition, 5, FloatTableWidgetItem(str(curGPS.speed)))

        # limit to 20 entries
        if (self.historyTable.rowCount() > 20):
            self.historyTable.setRowCount(20)