Python PyQt5.QtWidgets.QTableWidgetItem() Examples

The following are 30 code examples of PyQt5.QtWidgets.QTableWidgetItem(). These examples are extracted from open source projects. 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 Project: PyQt5-Apps   Author: taseikyo   File: main.py    License: GNU General Public License v3.0 8 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 #2
Source Project: pkmeter   Author: pkkid   File: pkconfig.py    License: 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 #3
Source Project: simnibs   Author: simnibs   File: main_gui.py    License: 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 #4
Source Project: idasec   Author: RobinDavid   File: AnalysisWidget.py    License: GNU Lesser General Public License v2.1 6 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 #5
Source Project: restatic   Author: Mebus   File: archive_tab.py    License: 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 Project: Computer-graphics   Author: Panda-Lewandowski   File: lab6.py    License: 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 #7
Source Project: Computer-graphics   Author: Panda-Lewandowski   File: lab7.py    License: 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 #8
Source Project: Computer-graphics   Author: Panda-Lewandowski   File: lab5.py    License: 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 Project: Computer-graphics   Author: Panda-Lewandowski   File: lab8.py    License: 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 #10
Source Project: PyPipboyApp   Author: matzman666   File: locationbrowser.py    License: 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 #11
Source Project: PyQt5-Apps   Author: taseikyo   File: main.py    License: 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 #12
Source Project: PyQt5-Apps   Author: taseikyo   File: main.py    License: 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 #13
Source Project: PyQt5-Apps   Author: taseikyo   File: main.py    License: 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 #14
Source Project: heap-viewer   Author: danigargu   File: magic.py    License: 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 #15
Source Project: pychemqt   Author: jjgomera   File: UI_pipe.py    License: 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 #16
Source Project: pychemqt   Author: jjgomera   File: UI_pipe.py    License: 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 #17
Source Project: pychemqt   Author: jjgomera   File: newComponent.py    License: 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 #18
Source Project: pychemqt   Author: jjgomera   File: UI_databank.py    License: 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 #19
Source Project: vorta   Author: borgbase   File: schedule_tab.py    License: 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 #20
Source Project: sparrow-wifi   Author: ghostop14   File: sparrowdialogs.py    License: 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 #21
Source Project: simnibs   Author: simnibs   File: main_gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.electrode = sim_struct.ELECTRODE()
        #self.electrode.definition = 'plane'
        self.centre = None
        self.pos_ydir = None
        self.current_box = QtWidgets.QDoubleSpinBox()
        self.current_box.setDecimals(3)
        self.current_box.setSuffix("mA")
        self.current_box.setMinimum(-10)
        self.current_box.setMaximum(10)
        self.current_box.setSingleStep(0.25)
        self.current = self.current_box.value()

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

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

        #self.color_item = QtWidgets.QTableWidgetItem('')

        self.name_item = QtWidgets.QTableWidgetItem('')

        self.transf_matrix = []


#Defies a row in the table on the TMS poslist tab 
Example #22
Source Project: idasec   Author: RobinDavid   File: TraceWidget.py    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
def add_chunk_trace_table(self, table, trace, k, index):
        i = index
        while k in trace.instrs:
            inst = trace.instrs[k]
            if k in trace.metas:
                for name, arg1, arg2 in trace.metas[k]:
                    if name == "wave":
                        infos = ["=", "========", "> Wave:"+str(arg1)]
                    elif name == "exception":
                        infos = ["", "", "Exception type:"+str(arg1)+" @handler:"+str(arg2)]
                    elif name == "module":
                        infos = ["", "Module", arg1]
                    else:
                        infos = ["", "", "Invalid"]
                    for col_id, cell in enumerate(infos):
                        newitem = QtWidgets.QTableWidgetItem(cell)
                        newitem.setFlags(newitem.flags() ^ QtCore.Qt.ItemIsEditable)
                        table.setItem(i, col_id, newitem)
                    i += 1
            info = [str(k), hex(inst.address)[:-1], inst.opcode]
            for col_id, cell in enumerate(info):
                newitem = QtWidgets.QTableWidgetItem(cell)
                newitem.setFlags(newitem.flags() ^ QtCore.Qt.ItemIsEditable)
                table.setItem(i, col_id, newitem)
            i += 1
            k += 1 
Example #23
Source Project: pyweed   Author: iris-edu   File: MyNumericTableWidgetItem.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def __lt__(self, other):
        if (isinstance(other, MyNumericTableWidgetItem)):
            selfDataValue = float(self.data(QtCore.Qt.UserRole))
            otherDataValue = float(other.data(QtCore.Qt.UserRole))
            return selfDataValue < otherDataValue
        else:
            return QtWidgets.QTableWidgetItem.__lt__(self, other) 
Example #24
Source Project: pyweed   Author: iris-edu   File: TableItems.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def stringWidget(self, s, **props):
        """ Create a new item displaying the given string """
        return self.applyProps(QtWidgets.QTableWidgetItem(s), **props) 
Example #25
Source Project: pyweed   Author: iris-edu   File: TableItems.py    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
def checkboxWidget(self, b, **props):
        """ Create a new checkbox widget showing the given boolean state """
        checkboxItem = self.applyProps(QtWidgets.QTableWidgetItem(), **props)
        checkboxItem.setFlags(QtCore.Qt.ItemIsEnabled)
        if b:
            checkboxItem.setCheckState(QtCore.Qt.Checked)
        else:
            checkboxItem.setCheckState(QtCore.Qt.Unchecked)
        return checkboxItem 
Example #26
Source Project: persepolis   Author: persepolisdm   File: setting.py    License: GNU General Public License v3.0 5 votes vote down vote up
def callBack(self, keys):
        # do nothing if keys is empty
        if not(keys):
            return

        # check that if shortcut used before.
        if keys in self.shortcuts_list:
            self.msgBox = QMessageBox()
            self.msgBox.setText(QCoreApplication.translate("setting_src_ui_tr", "<b><center>This shortcut has been used before!\
                    Use another one!</center></b>"))
            self.msgBox.setIcon(QMessageBox.Warning)
            reply = self.msgBox.exec_()

        # set new shortcut
        else:
            selected_row = self.shortcut_table.selectionModel().selectedRows()[0].row()

            item = QTableWidgetItem(keys)

            # align center
            item.setTextAlignment(0x0004 | 0x0080)

            # insert item in shortcut_table
            self.shortcut_table.setItem(selected_row, 1, item)

            # set keys in shortcuts_list
            self.shortcuts_list[selected_row] = keys

    # active color_comboBox only when user is select "Fusion" style. 
Example #27
Source Project: ocelot   Author: ocelot-collab   File: ebeam_table_ui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def setupUi(self, Ebeam_Table):
        Ebeam_Table.setObjectName("Ebeam_Table")
        Ebeam_Table.resize(700, 500)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Ebeam_Table.sizePolicy().hasHeightForWidth())
        Ebeam_Table.setSizePolicy(sizePolicy)
        self.gridLayout_2 = QtWidgets.QGridLayout(Ebeam_Table)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.table = QtWidgets.QTableWidget(Ebeam_Table)
        self.table.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.table.setRowCount(0)
        self.table.setColumnCount(2)
        self.table.setObjectName("table")
        item = QtWidgets.QTableWidgetItem()
        item.setTextAlignment(QtCore.Qt.AlignCenter)
        self.table.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        item.setTextAlignment(QtCore.Qt.AlignCenter)
        self.table.setHorizontalHeaderItem(1, item)
        self.table.verticalHeader().setVisible(False)
        self.gridLayout_2.addWidget(self.table, 0, 1, 1, 1)

        self.retranslateUi(Ebeam_Table)
        QtCore.QMetaObject.connectSlotsByName(Ebeam_Table) 
Example #28
Source Project: pyleecan   Author: Eomys   File: WMachineTable.py    License: Apache License 2.0 5 votes vote down vote up
def update_tab(self, machine):
        """Update the table to match the machine

        Parameters
        ----------
        self : WMachineTable
            A WMachineTable object
        """

        self.machine = machine
        desc_dict = self.machine.comp_desc_dict()

        self.tab_param.clear()
        # Set header
        self.tab_param.setColumnCount(2)
        item = QTableWidgetItem("Name")
        self.tab_param.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem("Value")
        self.tab_param.setHorizontalHeaderItem(1, item)
        # Set containt
        for ii, desc in enumerate(desc_dict):
            if desc["value"] is not None:
                self.tab_param.insertRow(ii)
                self.tab_param.setItem(ii, 0, QTableWidgetItem(desc["verbose"]))
                if desc["type"] is float:
                    txt = format(desc["value"], ".4g")
                else:
                    txt = str(desc["value"])
                if desc["unit"] not in ["", None]:
                    txt += " " + desc["unit"]
                self.tab_param.setItem(ii, 1, QTableWidgetItem(txt)) 
Example #29
Source Project: pyleecan   Author: Eomys   File: Ui_WMachineTable.py    License: Apache License 2.0 5 votes vote down vote up
def setupUi(self, WMachineTable):
        WMachineTable.setObjectName("WMachineTable")
        WMachineTable.resize(290, 357)
        WMachineTable.setMinimumSize(QtCore.QSize(290, 0))
        WMachineTable.setMaximumSize(QtCore.QSize(282, 16777215))
        self.verticalLayout = QtWidgets.QVBoxLayout(WMachineTable)
        self.verticalLayout.setObjectName("verticalLayout")
        self.in_name = QtWidgets.QLabel(WMachineTable)
        self.in_name.setAlignment(QtCore.Qt.AlignCenter)
        self.in_name.setObjectName("in_name")
        self.verticalLayout.addWidget(self.in_name)
        self.tab_param = QtWidgets.QTableWidget(WMachineTable)
        self.tab_param.setMinimumSize(QtCore.QSize(270, 0))
        self.tab_param.setMaximumSize(QtCore.QSize(260, 16777215))
        self.tab_param.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.tab_param.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents
        )
        self.tab_param.setAlternatingRowColors(True)
        self.tab_param.setColumnCount(2)
        self.tab_param.setObjectName("tab_param")
        self.tab_param.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.tab_param.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tab_param.setHorizontalHeaderItem(1, item)
        self.tab_param.horizontalHeader().setCascadingSectionResizes(False)
        self.tab_param.horizontalHeader().setStretchLastSection(True)
        self.tab_param.verticalHeader().setVisible(False)
        self.tab_param.verticalHeader().setCascadingSectionResizes(False)
        self.verticalLayout.addWidget(self.tab_param)
        self.b_mmf = QtWidgets.QPushButton(WMachineTable)
        self.b_mmf.setObjectName("b_mmf")
        self.verticalLayout.addWidget(self.b_mmf)

        self.retranslateUi(WMachineTable)
        QtCore.QMetaObject.connectSlotsByName(WMachineTable) 
Example #30
Source Project: dash-masternode-tool   Author: Bertrand256   File: columns_cfg_dlg.py    License: MIT License 5 votes vote down vote up
def setupUi(self):
        ui_columns_cfg_dlg.Ui_ColumnsConfigDlg.setupUi(self, self)
        self.setWindowTitle("Columns")
        self.setIcon(self.btnMoveBegin, "first-page@16px.png", rotate=90)
        self.setIcon(self.btnMoveEnd, "first-page@16px.png", rotate=-90)
        self.setIcon(self.btnMoveUp, "arrow-downward@16px.png", rotate=-180)
        self.setIcon(self.btnMoveDown, "arrow-downward@16px.png")
        self.tableWidget.verticalHeader().setSectionsMovable(True)

        self.tableWidget.verticalHeader().setDefaultSectionSize(
            self.tableWidget.verticalHeader().fontMetrics().height() + 8)

        self.tableWidget.verticalHeader().sectionMoved.connect(self.on_tableRowMoved)

        self.tableWidget.setRowCount(len(self.columns))
        for col_idx, col in enumerate(self.columns):
            item = QtWidgets.QTableWidgetItem()
            item.setText('  ')

            self.tableWidget.setVerticalHeaderItem(col_idx, item)

            visible = col[1]
            item = QtWidgets.QTableWidgetItem()
            item.setText(col[0])
            self.tableWidget.setItem(col_idx, 0, item)
            item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
            item.setCheckState(QtCore.Qt.Checked if visible else QtCore.Qt.Unchecked)

        self.update_buttons_state()
        self.initialized = True