Python PyQt5.QtWidgets 模块,QTableWidgetItem() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QTableWidgetItem()

项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
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)
项目:VIRTUAL-PHONE    作者:SumanKanrar-IEM    | 项目源码 | 文件源码
def open_sheet(self):
        #self.check_change = False
        path = ('./contacts.csv', 'CSV(*.csv)')
        print(path)
        if path[0] != '':
            with open(path[0], newline='') as csv_file:
                self.table_contacts.setRowCount(0)
                self.table_contacts.setColumnCount(5)
                my_file = csv.reader(csv_file, delimiter=',', quotechar='|')
                for row_data in my_file:
                    row = self.table_contacts.rowCount()
                    self.table_contacts.insertRow(row)
                    if len(row_data) > 10:
                        self.table_contacts.setColumnCount(len(row_data))
                    for column, stuff in enumerate(row_data):
                        item = QTableWidgetItem(stuff)
                        self.table_contacts.setItem(row, column, item)
        #self.check_change = True
        print(self.table_contacts.rowCount())
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def update(self):
        """
        update the table with updated fit parameters
        """

        # If the fit is not done, clear the parameters
        if not self._fit.fitter.fit_success or len(self._fit.experiments) == 0:
            self.clear()
            return

        # Grab fit results from csv
        self._csv_to_table()

        self.setRowCount(len(self._data))
        self.setColumnCount(len(self._data[0]))
        self.setHorizontalHeaderLabels(self._col_name)

        # load fit data into the table
        for i, row in enumerate(self._data):
            for j, col in enumerate(row):
                item = QW.QTableWidgetItem(col)
                self.setItem(i, j, item)
项目:binja_dynamics    作者:nccgroup    | 项目源码 | 文件源码
def _makewidget(val, center=False):
    """ Small helper function that builds a TableWidgetItem and sets up the font the way we want"""
    out = QtWidgets.QTableWidgetItem(str(val))
    out.setFlags(Qt.ItemIsEnabled)
    out.setFont(monospace)
    if(center):
        out.setTextAlignment(Qt.AlignCenter)
    return out
项目:face    作者:MOluwole    | 项目源码 | 文件源码
def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)

        self.__register__ = None
        self.__attendance____ = None

        self.btn_Register.clicked.connect(self.Register)
        self.btn_Attendance.clicked.connect(self.Attendance)
        self.btnSearch.clicked.connect(self.Search)
        self.report_date.setDate(QtCore.QDate.currentDate())

        cursor = connection.cursor()
        sql = "Select * from attendance"
        cursor.execute(sql)

        result = cursor.fetchall()
        rows = len(result)
        if rows <= 0:
            QMessageBox.about(self, "No Data", "No Attendance has been recorded yet")
        else:
            self.tableWidget.setRowCount(rows)
            self.tableWidget.setColumnCount(3)
            header_labels = ['Matric Number', 'Date', 'Status']
            self.tableWidget.setHorizontalHeaderLabels(header_labels)

            for count in range(0, rows):
                self.tableWidget.setItem(count, 0,
                                         QTableWidgetItem(str(result[count]["matric_num"].encode('ascii', 'ignore'))))
                self.tableWidget.setItem(count, 1, QTableWidgetItem(result[count]["dte"].encode('ascii', 'ignore')))
                self.tableWidget.setItem(count, 2, QTableWidgetItem(result[count]["status"].encode('ascii', 'ignore')))
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
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)
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
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)
项目:earthquakes    作者:iamosmanyilmaz    | 项目源码 | 文件源码
def createTable(self):
        q = LatestQuakes()
        c = 0

        self.tableWidget = QTableWidget()
        self.tableWidget.setVerticalHeaderLabels(('Row 1', 'Row 2', 'Row 3'))
        self.tableWidget.setRowCount(30)
        self.tableWidget.setColumnCount(7)
        self.tableWidget.setColumnWidth(0, 30)
        self.tableWidget.setColumnWidth(1, 160)

        for quake in q.work():
            self.tableWidget.setItem(c, 0, QTableWidgetItem(quake["text"]))
            self.tableWidget.setItem(c, 1, QTableWidgetItem(quake["name"]))
            self.tableWidget.setItem(c, 2, QTableWidgetItem(quake["time"]))
            self.tableWidget.setItem(c, 3, QTableWidgetItem(quake["hours"]))
            self.tableWidget.setItem(c, 4, QTableWidgetItem(quake["deep"]))
            self.tableWidget.setItem(c, 5, QTableWidgetItem(quake["longitude"][0]))
            self.tableWidget.setItem(c, 6, QTableWidgetItem(quake["latitude"][0]))
            c = c + 1

        self.tableWidget.move(0, 0)
        # table selection change
        # self.tableWidget.doubleClicked.connect(self.on_click)
项目:VIRTUAL-PHONE    作者:SumanKanrar-IEM    | 项目源码 | 文件源码
def createTable(self):
       # Create table
        self.tableWidget = QTableWidget()
        self.tableWidget.setRowCount(4)
        self.tableWidget.setColumnCount(2)
        self.tableWidget.setItem(0,0, QTableWidgetItem("Cell (1,1)"))
        self.tableWidget.setItem(0,1, QTableWidgetItem("Cell (1,2)"))
        self.tableWidget.setItem(1,0, QTableWidgetItem("Cell (2,1)"))
        self.tableWidget.setItem(1,1, QTableWidgetItem("Cell (2,2)"))
        self.tableWidget.setItem(2,0, QTableWidgetItem("Cell (3,1)"))
        self.tableWidget.setItem(2,1, QTableWidgetItem("Cell (3,2)"))
        self.tableWidget.setItem(3,0, QTableWidgetItem("Cell (4,1)"))
        self.tableWidget.setItem(3,1, QTableWidgetItem("Cell (4,2)"))
        self.tableWidget.move(0,0)

        # table selection change
        self.tableWidget.doubleClicked.connect(self.on_click)
项目:VIRTUAL-PHONE    作者:SumanKanrar-IEM    | 项目源码 | 文件源码
def open_sheet(self):
        self.check_change = False
        path = QFileDialog.getOpenFileName(self, 'Open CSV', os.getenv('HOME'), 'CSV(*.csv)')
        if path[0] != '':
            with open(path[0], newline='') as csv_file:
                self.setRowCount(0)
                self.setColumnCount(10)
                my_file = csv.reader(csv_file, delimiter=',', quotechar='|')
                for row_data in my_file:
                    row = self.rowCount()
                    self.insertRow(row)
                    if len(row_data) > 10:
                        self.setColumnCount(len(row_data))
                    for column, stuff in enumerate(row_data):
                        item = QTableWidgetItem(stuff)
                        self.setItem(row, column, item)
        self.check_change = True
项目:VIRTUAL-PHONE    作者:SumanKanrar-IEM    | 项目源码 | 文件源码
def open_sheet(self):
        self.check_change = False
        path = QFileDialog.getOpenFileName(self, 'Open CSV', os.getenv('HOME'), 'CSV(*.csv)')
        if path[0] != '':
            with open(path[0], newline='') as csv_file:
                self.setRowCount(0)
                self.setColumnCount(10)
                my_file = csv.reader(csv_file, dialect='excel')
                for row_data in my_file:
                    row = self.rowCount()
                    self.insertRow(row)
                    if len(row_data) > 10:
                        self.setColumnCount(len(row_data))
                    for column, stuff in enumerate(row_data):
                        item = QTableWidgetItem(stuff)
                        self.setItem(row, column, item)
        self.check_change = True
项目:binja_dynamics    作者:ehennenfent    | 项目源码 | 文件源码
def _makewidget(val, center=False):
    """ Small helper function that builds a TableWidgetItem and sets up the font the way we want"""
    out = QtWidgets.QTableWidgetItem(str(val))
    out.setFlags(Qt.ItemIsEnabled)
    out.setFont(monospace)
    if(center):
        out.setTextAlignment(Qt.AlignCenter)
    return out
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def fwChanged(self, flag = False):
        if not self.currentlyLoading:
            if self.currentFertName != "":
                if flag:
                    val = self.spinRef[self.currentFertName].value()
                else:
                    val = self.uiFert.spinFW.value()
                Wolke.Char.fertigkeiten[self.currentFertName].wert = val
                Wolke.Char.fertigkeiten[self.currentFertName].aktualisieren()
                self.uiFert.spinPW.setValue(Wolke.Char.fertigkeiten[self.currentFertName].probenwert)
                self.uiFert.spinPWT.setValue(Wolke.Char.fertigkeiten[self.currentFertName].probenwertTalent)
                self.modified.emit()
                #self.uiFert.tableWidget.setItem(self.rowRef[self.currentFertName],1,QtWidgets.QTableWidgetItem(str(Wolke.Char.fertigkeiten[self.currentFertName].wert)))
                if flag:
                    self.uiFert.spinFW.setValue(val)
                else:
                    self.spinRef[self.currentFertName].setValue(val)
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def fwChanged(self, flag = False):
        if not self.currentlyLoading:
            if self.currentFertName != "":
                if flag:
                    val = self.spinRef[self.currentFertName].value()
                else:
                    val = self.uiFert.spinFW.value()
                Wolke.Char.übernatürlicheFertigkeiten[self.currentFertName].wert = val
                Wolke.Char.übernatürlicheFertigkeiten[self.currentFertName].aktualisieren()
                self.uiFert.spinPW.setValue(Wolke.Char.übernatürlicheFertigkeiten[self.currentFertName].probenwertTalent)
                #self.uiFert.spinPWT.setValue(Wolke.Char.übernatürlicheFertigkeiten[self.currentFertName].probenwertTalent)
                self.modified.emit()
                #self.uiFert.tableWidget.setItem(self.rowRef[self.currentFertName],1,QtWidgets.QTableWidgetItem(str(Wolke.Char.übernatürlicheFertigkeiten[self.currentFertName].wert)))
                if flag:
                    self.uiFert.spinFW.setValue(val)
                else:
                    self.spinRef[self.currentFertName].setValue(val)
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def tab_set_value(tab,y,x,value):
    if type(tab.cellWidget(y, x))==QComboBox:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).setCurrentIndex(tab.cellWidget(y, x).findText(value))
        tab.cellWidget(y, x).blockSignals(False)
    elif type(tab.cellWidget(y, x))==QComboBoxLang:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).setCurrentIndex(tab.cellWidget(y, x).findText(value))
        tab.cellWidget(y, x).blockSignals(False)
    elif type(tab.cellWidget(y,x))==gpvdm_select:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).setText(value)
        tab.cellWidget(y, x).blockSignals(False)
    elif type(tab.cellWidget(y,x))==gtkswitch:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).set_value(str2bool(value))
        tab.cellWidget(y, x).blockSignals(False)
    else:
        item = QTableWidgetItem(str(value))
        tab.setItem(y,x,item)
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def insert_row(self,i,file_name,token,path,value):
        self.tab.blockSignals(True)
        self.tab.insertRow(i)

        item = QTableWidgetItem(file_name)
        self.tab.setItem(i,0,item)

        item = QTableWidgetItem(token)
        self.tab.setItem(i,1,item)


        self.item = gpvdm_select()
        self.item.setText(path)
        self.item.button.clicked.connect(self.callback_show_list)

        self.tab.setCellWidget(i,2,self.item)

        item = QTableWidgetItem(value)
        self.tab.setItem(i,3,item)
        self.tab.blockSignals(False)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def begin_search(self, root_path, file_type, ignore_case, keyword):
        counts = 0
        for root, dirs, files in os.walk(root_path):
            for each_file in files:
                if is_valid_file_type(each_file, file_type):
                    path = root + os.sep + each_file
                    line_content = search_keyword_infile(path, keyword, ignore_case)
                    if line_content:
                        self.result_table.insertRow(counts)

                        content_path = QTableWidgetItem(".{}".format(path[len(root_path):]))
                        self.result_table.setItem(counts, 0, content_path)

                        content = QTableWidgetItem(line_content.strip())
                        self.result_table.setItem(counts, 1, content)

                        counts += 1
                        self.result_table.setRowCount(counts)

        self.state_label.setText("????")
项目:idasec    作者:RobinDavid    | 项目源码 | 文件源码
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
项目:lyk2017-Python-Example    作者:ilteriskesk    | 项目源码 | 文件源码
def kullaniciListesi(self):
        try:
            kisiler = json.load(open(self.json_file, "r"))

        except:
            kisiler = []

        self.kullanici_listesi.clearContents()
        self.kullanici_listesi.setRowCount(len(kisiler))

        satir = 0
        for kisi in kisiler:
            telefon = QTableWidgetItem(kisi.get("telefon"))
            isim = QTableWidgetItem(kisi.get("isim"))
            self.kullanici_listesi.setItem(satir, 0, isim)
            self.kullanici_listesi.setItem(satir, 1, telefon)
            satir += 1
项目:Default-Credit-Card-Prediction    作者:AlexPnt    | 项目源码 | 文件源码
def show_pearson_correlation(self):
        if self.dataset_loaded:
            self.feature_inspection_fig.hide()
            self.correlation_table.show()
            correlation_matrix=pearson_correlation_matrix(self.X)


            #initialize rows, columns and headers
            self.correlation_table.setRowCount(0)
            self.correlation_table.setColumnCount(0)
            for i in xrange(len(self.X[0])):
                self.correlation_table.insertRow(i)
                self.correlation_table.insertColumn(i)
                self.correlation_table.setHorizontalHeaderItem(i,QtWidgets.QTableWidgetItem(self.features[i]))
                self.correlation_table.setVerticalHeaderItem(i,QtWidgets.QTableWidgetItem(self.features[i]))

            #fill table data
            for i in xrange(len(self.X[0])):
                for j in xrange(len(self.X[0])):
                    self.correlation_table.setItem(i,j,QtWidgets.QTableWidgetItem(str(correlation_matrix[i][j])))
        else:
            QtWidgets.QMessageBox.information(self, "Data Not Found","Please load a dataset first.")

    #Apply data tranformation
项目:polichombr    作者:ANSSI-FR    | 项目源码 | 文件源码
def get_widgets(self):
            widgets = {}
            widgets["address"] = QtWidgets.QTableWidgetItem(self.address)
            widgets["curname"] = QtWidgets.QTableWidgetItem(self.curname)
            widgets["machoc"] = QtWidgets.QTableWidgetItem(self.machoc)
            widgets["proposed"] = QtWidgets.QTableWidgetItem(self.proposed)

            return widgets
项目:face    作者:MOluwole    | 项目源码 | 文件源码
def Search(self):
        matric_num = self.report_matric.text()
        search_date = self.report_date.date().toString("yyyy-MM-dd")

        if matric_num == "" and search_date == "":
            QMessageBox.about(self, "Invalid Parameters", "Please Provide a search Query to continue")
        else:
            self.tableWidget.setRowCount(0)
            if matric_num != "":
                sql = "Select * from attendance where matric_num = %s"
                cursor = connection.cursor()
                cursor.execute(sql, matric_num)
                result = cursor.fetchall()

            else:
                sql = "Select * from attendance where dte = %s"
                cursor = connection.cursor()
                cursor.execute(sql, search_date)
                result = cursor.fetchall()

            if len(result) > 0:
                self.tableWidget.setRowCount(len(result))
                self.tableWidget.setColumnCount(3)
                header_labels = ['Matric Number', 'Date', 'Status']
                self.tableWidget.setHorizontalHeaderLabels(header_labels)

                for count in range(0, len(result)):
                    self.tableWidget.setItem(count, 0, QTableWidgetItem(
                        str(result[count]["matric_num"].encode('ascii', 'ignore'))))
                    self.tableWidget.setItem(count, 1,
                                             QTableWidgetItem(result[count]["dte"].encode('ascii', 'ignore')))
                    self.tableWidget.setItem(count, 2,
                                             QTableWidgetItem(result[count]["status"].encode('ascii', 'ignore')))
            else:
                QMessageBox.about(self, "No Data", "No Data has been recorded")
项目:Computer-graphics    作者:Panda-Lewandowski    | 项目源码 | 文件源码
def add_point(point):
    global w
    if w.input_rect:
        w.pen.setColor(black)
        if w.point_now_rect is None:
            w.point_now_rect = point
            w.point_lock = point
            add_row(w.table_rect)
            i = w.table_rect.rowCount() - 1
            item_x = QTableWidgetItem("{0}".format(point.x()))
            item_y = QTableWidgetItem("{0}".format(point.y()))
            w.table_rect.setItem(i, 0, item_x)
            w.table_rect.setItem(i, 1, item_y)
        else:
            w.edges.append(point)
            w.point_now_rect = point
            add_row(w.table_rect)
            i = w.table_rect.rowCount() - 1
            item_x = QTableWidgetItem("{0}".format(point.x()))
            item_y = QTableWidgetItem("{0}".format(point.y()))
            w.table_rect.setItem(i, 0, item_x)
            w.table_rect.setItem(i, 1, item_y)
            item_x = w.table_rect.item(i-1, 0)
            item_y = w.table_rect.item(i-1, 1)
            w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen)
    if w.input_bars:
        w.pen.setColor(red)
        if w.point_now_bars is None:
            w.point_now_bars = point
        else:
            w.lines.append([[w.point_now_bars.x(), w.point_now_bars.y()],
                            [point.x(), point.y()]])

            add_row(w.table_bars)
            i = w.table_bars.rowCount() - 1
            item_b = QTableWidgetItem("[{0}, {1}]".format(w.point_now_bars.x(), w.point_now_bars.y()))
            item_e = QTableWidgetItem("[{0}, {1}]".format(point.x(), point.y()))
            w.table_bars.setItem(i, 0, item_b)
            w.table_bars.setItem(i, 1, item_e)
            w.scene.addLine(w.point_now_bars.x(), w.point_now_bars.y(), point.x(), point.y(), w.pen)
            w.point_now_bars = None
项目:VIRTUAL-PHONE    作者:SumanKanrar-IEM    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.form_widget = MyTable(10, 7)
        self.setCentralWidget(self.form_widget)
        col_headers = ['Name', 'Company', 'Mobile', 'Email ID', 'Address', 'Designation', 'DOB']
        self.form_widget.setHorizontalHeaderLabels(col_headers)

        #number = QTableWidgetItem('10')
        #self.form_widget.setCurrentCell(1, 1)
        #self.form_widget.setItem(1, 1, number)

        self.show()
项目:VIRTUAL-PHONE    作者:SumanKanrar-IEM    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.form_widget = MyTable(10, 10)
        self.setCentralWidget(self.form_widget)
        col_headers = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
        self.form_widget.setHorizontalHeaderLabels(col_headers)

        number = QTableWidgetItem('10')
        self.form_widget.setCurrentCell(1, 1)
        self.form_widget.setItem(1, 1, number)

        self.show()
项目:BATS-Bayesian-Adaptive-Trial-Simulator    作者:ContaTP    | 项目源码 | 文件源码
def switchPatNum(self):

        if self.patNum_flag:

            self.patColHeaders = []
            for i in range(self.nStage):

                self.patColHeaders.append("Stage "+str(i+1))

            self.patNum_tableWidget.setRowCount(1)
            self.patNum_tableWidget.setColumnCount(self.nStage)
            self.patNum_tableWidget.setCurrentCell(-1, -1)
            self.patNum_tableWidget.setHorizontalHeaderLabels(self.patColHeaders)

            # If unchanged, load the settings last time
            if self.nStage == len(self.ns_list):

                for j in range(self.nStage):

                    self.patNum_tableWidget.setItem(0, j, QtWidgets.QTableWidgetItem(str(int(self.ns_list[j]))))

            self.nStage_comboBox.setEnabled(False)
            self.nArm_comboBox.setEnabled(False)

        else:

            self.assignPatient_btn.setFocus()
            self.nStage_comboBox.setEnabled(True)
            self.nArm_comboBox.setEnabled(True)


        self.patNum_Frame.setVisible(self.patNum_flag)
        self.patNum_flag = not self.patNum_flag


    # Toggle for patient frame
项目:BATS-Bayesian-Adaptive-Trial-Simulator    作者:ContaTP    | 项目源码 | 文件源码
def switchStopBoundary(self):

        if self.stopBoundary_flag:

            self.patColHeaders = []
            for i in range(self.nStage):

                self.patColHeaders.append("Stage "+str(i+1))

            # There are two rows, corresponding to the futility and efficacy boundary
            self.stopBoundary_tableWidget.setRowCount(2)
            self.stopBoundary_tableWidget.setColumnCount(self.nStage)
            self.stopBoundary_tableWidget.setCurrentCell(-1, -1)
            self.stopBoundary_tableWidget.setHorizontalHeaderLabels(self.patColHeaders)
            self.stopBoundary_tableWidget.setVerticalHeaderLabels(["Futility", "Efficacy"])

            # If unchanged, load the settings last time
            if self.nStage == len(self.fut_list) and self.nStage == len(self.eff_list):

                for j in range(self.nStage):

                    self.stopBoundary_tableWidget.setItem(0, j, QtWidgets.QTableWidgetItem(str(self.fut_list[j])))
                    self.stopBoundary_tableWidget.setItem(1, j, QtWidgets.QTableWidgetItem(str(self.eff_list[j])))

            self.nStage_comboBox.setEnabled(False)
            self.nArm_comboBox.setEnabled(False)

        else:

            self.setStopBoundary_btn.setFocus()
            self.nStage_comboBox.setEnabled(True)
            self.nArm_comboBox.setEnabled(True)


        self.stopBoundary_Frame.setVisible(self.stopBoundary_flag)
        self.stopBoundary_flag = not self.stopBoundary_flag


    # Toggle for added patient frame
项目:BATS-Bayesian-Adaptive-Trial-Simulator    作者:ContaTP    | 项目源码 | 文件源码
def switchPredNum(self):

        if self.predNum_flag:

            self.patColHeaders = []
            for i in range(self.nStage):

                self.patColHeaders.append("Stage "+str(i+1))

            self.predNum_tableWidget.setRowCount(1)
            self.predNum_tableWidget.setColumnCount(self.nStage)
            self.predNum_tableWidget.setCurrentCell(-1, -1)
            self.predNum_tableWidget.setHorizontalHeaderLabels(self.patColHeaders)

            # If unchanged, load the settings last time
            if self.nStage == len(self.predns_list):

                for j in range(self.nStage):

                    self.predNum_tableWidget.setItem(0, j, QtWidgets.QTableWidgetItem(str(int(self.predns_list[j]))))

            self.nStage_comboBox.setEnabled(False)
            self.nArm_comboBox.setEnabled(False)
            self.predict_checkBox.setEnabled(False)

        else:

            self.predNum_btn.setFocus()
            self.nStage_comboBox.setEnabled(True)
            self.nArm_comboBox.setEnabled(True)
            self.predict_checkBox.setEnabled(True)

        self.predNum_Frame.setVisible(self.predNum_flag)
        self.predNum_flag = not self.predNum_flag


    # Save effective size
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def appendLine(self, line = None):
        """
        Add a line to the table. The new line is inserted before the selected line, or at the end of the table is no line is selected
        @param line: a string list containing all the values for this lines. If line is None, an empty line is inserted
        """
        selected_row = self.tablewidget.currentRow()
        if selected_row < 0 or len(self.tablewidget.selectedIndexes()) <= 0: #Trick to be able to insert lines before the first and after the last line (click on column name to unselect the lines)
            selected_row = self.tablewidget.rowCount()

        self.tablewidget.insertRow(selected_row)

        #If provided, fill the table with the content of the line list
        if line is not None and isinstance(line, (list, tuple)) and len(line) >= self.tablewidget.columnCount():
            for i in range(self.tablewidget.columnCount()):
                #self.tablewidget.setItem(selected_row, i, QTableWidgetItem(line[i]))
                self.setCellValue(selected_row, i, line[i])
        else:
            for i in range(self.tablewidget.columnCount()):
                self.setCellValue(selected_row, i, "") #Don't remove this line, otherwise the subclasses won't be able to set custom widget into the table.

        #Resize the columns to the content, except for the last one
        for i in range(self.tablewidget.columnCount() - 1):
            self.tablewidget.resizeColumnToContents(i)

        #Resize the rows to the content
        for i in range(self.tablewidget.rowCount()):
            self.tablewidget.resizeRowToContents(i)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def setCellValue(self, line, column, value):
        """
        Default implementation for filling cells use Qt default QTableWidgetItem. One can subclass to provide another implementation, like inserting various Widget into the table.
        @param line: line number (int)
        @param column: column number (int)
        @param value: cell content (string)
        """
        self.tablewidget.setItem(line, column, QTableWidgetItem(value))
项目:ripr    作者:pbiernat    | 项目源码 | 文件源码
def update_table(self, emuchunks):
            '''
                This function updates the table with new code objects received from the packager
                at the end of a "ripping" process.
            '''
            if (not self.qtAvailable):
                return
            self._table.setRowCount(len(emuchunks))
            self._table.emuchunks = emuchunks
            row = 0
            for chunkName in emuchunks:
                nameField =  QtWidgets.QTableWidgetItem(chunkName)
                nameField.setFlags(Qt.ItemIsEnabled)

                startAddr = QtWidgets.QTableWidgetItem('0x%.8x' % emuchunks[chunkName].startaddr)
                startAddr.setFlags(Qt.ItemIsEnabled)

                endAddr = QtWidgets.QTableWidgetItem('0x%.8x' % (int(emuchunks[chunkName].startaddr) + int(emuchunks[chunkName].codelen)))
                endAddr.setFlags(Qt.ItemIsEnabled)

                self._table.setItem(row, 0, nameField)
                self._table.setItem(row, 1, startAddr)
                self._table.setItem(row, 2, endAddr)
                row += 1

            self._core.show()
            self._core.selectTab(self)
            self.show()


        ### Convenience wrappers for some frequently used things
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def updateTalentRow(self):
        for i in range(self.uiFert.tableWidget.rowCount()):
            fert = self.uiFert.tableWidget.item(i,0).text()
            #self.uiFert.tableWidget.setItem(i,2,QtWidgets.QTableWidgetItem(str(len(Wolke.Char.fertigkeiten[fert].gekaufteTalente))))
            self.labelRef[fert].setText(str(len(Wolke.Char.fertigkeiten[fert].gekaufteTalente)))
项目:Sephrasto    作者:Aeolitus    | 项目源码 | 文件源码
def updateTalentRow(self):
        for i in range(self.uiFert.tableWidget.rowCount()):
            fert = self.uiFert.tableWidget.item(i,0).text()
            #self.uiFert.tableWidget.setItem(i,2,QtWidgets.QTableWidgetItem(str(len(Wolke.Char.übernatürlicheFertigkeiten[fert].gekaufteTalente))))
            self.labelRef[fert].setText(str(len(Wolke.Char.übernatürlicheFertigkeiten[fert].gekaufteTalente)))
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def add_row(self,pos,name,top_btm,active,start,width,depth,voltage):

        pos= tab_insert_row(self.tab)

        self.tab.blockSignals(True)
        self.tab.setItem(pos,0,QTableWidgetItem(name))

        combobox = QComboBoxLang()
        combobox.addItemLang("top",_("top"))
        combobox.addItemLang("bottom",_("bottom"))

        self.tab.setCellWidget(pos,1, combobox)
        combobox.setValue_using_english(top_btm.lower())
        #combobox.setCurrentIndex(combobox.findText(top_btm.lower()))
        combobox.currentIndexChanged.connect(self.save)

        combobox = QComboBoxLang()
        combobox.addItemLang("true",_("true"))
        combobox.addItemLang("false",_("false"))

        self.tab.setCellWidget(pos,2, combobox)
        combobox.setValue_using_english(active.lower()) #setCurrentIndex(combobox.findText(active.lower()))
        combobox.currentIndexChanged.connect(self.save)

        self.tab.setItem(pos,3,QTableWidgetItem(start))
        self.tab.setItem(pos,4,QTableWidgetItem(width))
        self.tab.setItem(pos,5,QTableWidgetItem(depth))
        self.tab.setItem(pos,6,QTableWidgetItem(voltage))


        self.tab.blockSignals(False)
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def insert_row_mm(self,i,file_name,token,path,function,max_value,min_value,error):
        self.tab_mm.blockSignals(True)
        self.tab_mm.insertRow(i)

        item = QTableWidgetItem(file_name)
        self.tab_mm.setItem(i,0,item)

        item = QTableWidgetItem(token)
        self.tab_mm.setItem(i,1,item)

        self.item = gpvdm_select()
        self.item.setText(path)
        self.item.button.clicked.connect(self.callback_show_list_src)
        self.tab_mm.setCellWidget(i,2,self.item)


        item = QTableWidgetItem(function)
        self.tab_mm.setItem(i,3,item)

        item = QTableWidgetItem(max_value)
        self.tab_mm.setItem(i,4,item)

        item = QTableWidgetItem(min_value)
        self.tab_mm.setItem(i,5,item)

        item = QTableWidgetItem(error)
        self.tab_mm.setItem(i,6,item)

        self.tab_mm.blockSignals(False)
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def insert_row_math(self,i,file_a,token_a,path_a,file_b,token_b,path_b,equation):
        self.tab_math.blockSignals(True)
        self.tab_math.insertRow(i)

        item = QTableWidgetItem(file_a)
        self.tab_math.setItem(i,0,item)

        item = QTableWidgetItem(token_a)
        self.tab_math.setItem(i,1,item)

        self.item = gpvdm_select()
        self.item.setText(path_a)
        self.item.button.clicked.connect(self.callback_show_list_equation_a)
        self.tab_math.setCellWidget(i,2,self.item)

        item = QTableWidgetItem(file_b)
        self.tab_math.setItem(i,3,item)

        item = QTableWidgetItem(token_b)
        self.tab_math.setItem(i,4,item)

        self.item = gpvdm_select()
        self.item.setText(path_b)
        self.item.button.clicked.connect(self.callback_show_list_equation_b)
        self.tab_math.setCellWidget(i,5,self.item)

        item = QTableWidgetItem(equation)
        self.tab_math.setItem(i,6,item)

        self.tab_math.blockSignals(False)
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def insert_row(self,i,enabled,src_file,src_token,src_path,dest_file,dest_token,dest_path):
        self.tab.blockSignals(True)
        self.tab.insertRow(i)

        item = gtkswitch()
        item.set_value(str2bool(enabled))
        item.changed.connect(self.tab_changed)
        self.tab.setCellWidget(i,0,item)

        item = QTableWidgetItem(src_file)
        self.tab.setItem(i,1,item)

        item = QTableWidgetItem(src_token)
        self.tab.setItem(i,2,item)

        self.item = gpvdm_select()
        self.item.setText(src_path)
        self.item.button.clicked.connect(self.callback_show_list_src)
        self.tab.setCellWidget(i,3,self.item)

        item = QTableWidgetItem(dest_file)
        self.tab.setItem(i,4,item)

        item = QTableWidgetItem(dest_token)
        self.tab.setItem(i,5,item)

        self.item = gpvdm_select()
        self.item.setText(dest_path)
        self.item.button.clicked.connect(self.callback_show_list_dest)
        self.tab.setCellWidget(i,6,self.item)

        self.tab.blockSignals(False)
项目:PyTrader    作者:didw    | 项目源码 | 文件源码
def set_automated_stocks(self):
        file_list = ["../data/sell_list.txt", "../data/buy_list.txt"]
        automated_stocks = []

        try:
            for file in file_list:
                # utf-8? ??? ???
                # cp949 ???? ????? encoding ??
                with open(file, 'rt', encoding='utf-8') as f:
                    stocks_list = f.readlines()
                    automated_stocks += stocks_list
        except Exception as e:
            print(e)
            e.msg = "set_automated_stocks() ??"
            self.show_dialog('Critical', e)
            return

        # ??? ?? ??
        cnt = len(automated_stocks)
        self.automatedStocksTable.setRowCount(cnt)

        # ???? ??
        for i in range(cnt):
            stocks = automated_stocks[i].split(';')
            for j in range(len(stocks)):
                if j == 1:
                    name = self.kiwoom.get_master_code_name(stocks[j].rstrip())
                    item = QTableWidgetItem(name)
                else:
                    item = QTableWidgetItem(stocks[j].rstrip())
                item.setTextAlignment(Qt.AlignVCenter | Qt.AlignCenter)
                self.automatedStocksTable.setItem(i, j, item)
        self.automatedStocksTable.resizeRowsToContents()
项目:uitester    作者:IfengAutomation    | 项目源码 | 文件源码
def set_table_widget(self):
        header_text_list = ['case_id', 'case??', '??id', '????', '????', '????']
        row_count = len(self.task_records) if self.task_records else 0
        column_count = len(header_text_list)
        self.report_table_widget.setColumnCount(column_count)
        self.report_table_widget.setRowCount(row_count)
        self.report_table_widget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.report_table_widget.horizontalHeader().setStyleSheet("QHeaderView::section{background: #ECF5FF;}")
        for column in range(0, self.report_table_widget.columnCount()):
            table_header_item = QTableWidgetItem(header_text_list[column])
            table_header_item.setFont(QFont("Roman times", 12, QFont.Bold))
            self.report_table_widget.setHorizontalHeaderItem(column, table_header_item)
        if self.task_records:
            for i, report in enumerate(self.task_records):
                case_id = str(report.case_id) if report.case_id else ''
                case_name = report.case.name if report.case else ''
                self.report_table_widget.setItem(i, 0, QTableWidgetItem(case_id))
                self.report_table_widget.setItem(i, 1, QTableWidgetItem(case_name))
                self.report_table_widget.setItem(i, 2, QTableWidgetItem(report.device_id))
                self.report_table_widget.setItem(i, 3,
                                                 QTableWidgetItem(report.start_time.strftime("%Y-%m-%d %H:%M:%S")))
                self.report_table_widget.setItem(i, 4,
                                                 QTableWidgetItem(report.end_time.strftime("%Y-%m-%d %H:%M:%S")))
                status = '??' if report.status == 0 else '??'
                self.report_table_widget.setItem(i, 5, QTableWidgetItem(status))
        self.report_table_widget.cellClicked.connect(self.cell_clicked)
        self.report_table_widget.resizeColumnsToContents()  # Adjust the width according to the content
        self.report_table_widget.horizontalHeader().setStretchLastSection(True)
项目:uitester    作者:IfengAutomation    | 项目源码 | 文件源码
def set_table_widget(self):
        header_text_list = ['id', '????', '????', '??', '???', '???']
        self.task_record_statses = get_task_record_stats()
        row_count = len(self.task_record_statses) if self.task_record_statses else 0
        column_count = len(header_text_list)
        self.event_table_widget.setColumnCount(column_count)
        self.event_table_widget.setRowCount(row_count)
        self.event_table_widget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.event_table_widget.horizontalHeader().setStyleSheet("QHeaderView::section{background:  #ECF5FF;}")
        for column in range(0, self.event_table_widget.columnCount()):
            table_header_item = QTableWidgetItem(header_text_list[column])
            table_header_item.setFont(QFont("Roman times", 12, QFont.Bold))
            self.event_table_widget.setHorizontalHeaderItem(column, table_header_item)
        if self.task_record_statses:
            for i, task_record_stats in enumerate(self.task_record_statses):
                self.event_table_widget.setItem(i, 0, QTableWidgetItem(str(task_record_stats.id)))
                self.event_table_widget.setItem(i, 1, QTableWidgetItem(
                    task_record_stats.start_time.strftime("%Y-%m-%d %H:%M:%S")))
                self.event_table_widget.setItem(i, 2, QTableWidgetItem(
                    task_record_stats.end_time.strftime("%Y-%m-%d %H:%M:%S")))
                self.event_table_widget.setItem(i, 3, QTableWidgetItem(str(task_record_stats.total_count)))
                self.event_table_widget.setItem(i, 4, QTableWidgetItem(str(task_record_stats.pass_count)))
                self.event_table_widget.setItem(i, 5, QTableWidgetItem(str(task_record_stats.fail_count)))
        self.event_table_widget.cellClicked.connect(self.cell_clicked)
        self.event_table_widget.resizeColumnsToContents()  # Adjust the width according to the content
        self.event_table_widget.horizontalHeader().setStretchLastSection(True)
项目:climate    作者:FIDS-UWO    | 项目源码 | 文件源码
def knn_add_file(self):
        varname = self.ui.knnVarNameEdit.text()
        fl = self.ui.knnInputEdit.text()
        perturb = self.ui.knnPerturbation.currentIndex()

        rowIdx = self.ui.knnTableWidget.rowCount()
        self.ui.knnTableWidget.insertRow(rowIdx)

        varname_item = QtWidgets.QTableWidgetItem(varname)
        fl_item = QtWidgets.QTableWidgetItem(fl)
        perturbation_item = QtWidgets.QTableWidgetItem(str(perturb))

        self.ui.knnTableWidget.setItem(rowIdx, 0, varname_item)
        self.ui.knnTableWidget.setItem(rowIdx, 1, fl_item)
        self.ui.knnTableWidget.setItem(rowIdx, 2, perturbation_item)
项目:climate    作者:FIDS-UWO    | 项目源码 | 文件源码
def paste(self):
        data = QtWidgets.QApplication.clipboard().text().split('\n')

        for i, row in enumerate(data):
            for j, element in enumerate(row.split('\t')):
                self.setItem(i, j, QtWidgets.QTableWidgetItem(element))


# Created by: PyQt5 UI code generator 5.6
项目:RFID-System    作者:DecaturMakers    | 项目源码 | 文件源码
def buildTable():
    cconn, data = SQL_Handler.connectToDatabase('fobs', form.UsernameField.text(), form.PasswordField.text(), 'localhost')
    form2.sqlTable.clear()
    SQL_Handler.getAndSetData(cconn)
    form2.sqlTable.setColumnCount(len(data))
    form2.sqlTable.setRowCount(len(list(data.values())[0]))
    form2.sqlTable.setHorizontalHeaderLabels(sorted([d for d in data.keys()]))
    form2.sqlTable.resizeRowsToContents()
    form2.sqlTable.resizeColumnsToContents()
    for col, key in enumerate(sorted(data.keys())):
        for row, item in enumerate(data[key]):
            itemWidget = QTableWidgetItem(str(item))
            form2.sqlTable.setItem(row, col, itemWidget)
项目:reaper    作者:ScriptSmith    | 项目源码 | 文件源码
def table_fill(self, table_data, field_names):
        for row_count, row in enumerate(table_data):
            for col_count, col in enumerate(field_names):
                value = row[col]
                if not isinstance(value, str):
                    value = str(value)

                self.tableWidget.setItem(row_count, col_count,
                                         QtWidgets.QTableWidgetItem(
                                             value))
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def setFormatValue(self, row, column, value):
        self.allFormatsTable.setItem(row, column, QTableWidgetItem(value))
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def setFormatValue(self, row, column, value):
        self.allFormatsTable.setItem(row, column, QTableWidgetItem(value))
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def newLang_action(self):
        if len(self.memoData['fileList'].keys()) == 0:
            print("You need have UI name structure loaded in order to create a new language.")
        else:
            text, ok = QtWidgets.QInputDialog.getText(self, 'New Translation Creation', 'Enter language file name (eg. lang_cn):')
            if ok:
                if text in self.memoData['fileList'].keys():
                    print("This Language already in the table.")
                else:
                    self.uiList['dict_table'].insertColumn(self.uiList['dict_table'].columnCount())
                    index = self.uiList['dict_table'].columnCount() - 1
                    self.uiList['dict_table'].setHorizontalHeaderItem(index, QtWidgets.QTableWidgetItem(text) )
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def changeTableHeader(self, index):
        table = self.uiList["dict_table"]
        oldHeader = str(table.horizontalHeaderItem(index).text())
        text, ok = QtWidgets.QInputDialog.getText(self, 'Change header label for column %d' % index,'Header:',QtWidgets.QLineEdit.Normal, oldHeader)
        if ok:
            if text in self.memoData['fileList'].keys():
                print("This Language already in the table.")
            else:
                table.setHorizontalHeaderItem(index, QtWidgets.QTableWidgetItem(text) )
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def memory_to_source_ui(self):
        # update ui once memory gets update
        txt='\n'.join([row for row in self.memoData['fileList']])
        self.uiList['source_txtEdit'].setText(txt)
        # table
        table = self.uiList['dict_table']
        table.clear()
        table.setRowCount(0)
        table.setColumnCount(0)

        headers = ["UI Name"]
        table.insertColumn(table.columnCount())
        for key in self.memoData['fileList']:
            headers.append(key)
            table.insertColumn(table.columnCount())
        table.setHorizontalHeaderLabels(headers)

        ui_name_ok = 0
        translate = 1
        for file in self.memoData['fileList']:
            for row, ui_name in enumerate(self.memoData['fileList'][file]):
                #create ui list
                if ui_name_ok == 0:
                    ui_item = QtWidgets.QTableWidgetItem(ui_name)
                    table.insertRow(table.rowCount())
                    table.setItem(row, 0, ui_item)
                translate_item = QtWidgets.QTableWidgetItem(self.memoData['fileList'][file][ui_name])
                table.setItem(row, translate, translate_item)
            ui_name_ok = 1
            translate +=1
项目:idasec    作者:RobinDavid    | 项目源码 | 文件源码
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