当前位置: 首页>>代码示例>>Python>>正文


Python QTableWidget.columnCount方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QTableWidget.columnCount方法的典型用法代码示例。如果您正苦于以下问题:Python QTableWidget.columnCount方法的具体用法?Python QTableWidget.columnCount怎么用?Python QTableWidget.columnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QTableWidget的用法示例。


在下文中一共展示了QTableWidget.columnCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SpreadSheet

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]

#.........这里部分代码省略.........
        else:
            item.setData(Qt.EditRole, text)
        self.table.viewport().update()

    def selectColor(self):
        item = self.table.currentItem()
        color = item and QColor(item.background()) or self.table.palette().base().color()
        color = QColorDialog.getColor(color, self)
        if not color.isValid():
            return
        selected = self.table.selectedItems()
        if not selected:
            return
        for i in selected:
            i and i.setBackground(color)
        self.updateColor(self.table.currentItem())

    def selectFont(self):
        selected = self.table.selectedItems()
        if not selected:
            return
        font, ok = QFontDialog.getFont(self.font(), self)
        if not ok:
            return
        for i in selected:
            i and i.setFont(font)

    def runInputDialog(self, title, c1Text, c2Text, opText,
                       outText, cell1, cell2, outCell):
        rows = []
        cols = []
        for r in range(self.table.rowCount()):
            rows.append(str(r + 1))
        for c in range(self.table.columnCount()):
            cols.append(chr(ord('A') + c))
        addDialog = QDialog(self)
        addDialog.setWindowTitle(title)
        group = QGroupBox(title, addDialog)
        group.setMinimumSize(250, 100)
        cell1Label = QLabel(c1Text, group)
        cell1RowInput = QComboBox(group)
        c1Row, c1Col = decode_pos(cell1)
        cell1RowInput.addItems(rows)
        cell1RowInput.setCurrentIndex(c1Row)
        cell1ColInput = QComboBox(group)
        cell1ColInput.addItems(cols)
        cell1ColInput.setCurrentIndex(c1Col)
        operatorLabel = QLabel(opText, group)
        operatorLabel.setAlignment(Qt.AlignHCenter)
        cell2Label = QLabel(c2Text, group)
        cell2RowInput = QComboBox(group)
        c2Row, c2Col = decode_pos(cell2)
        cell2RowInput.addItems(rows)
        cell2RowInput.setCurrentIndex(c2Row)
        cell2ColInput = QComboBox(group)
        cell2ColInput.addItems(cols)
        cell2ColInput.setCurrentIndex(c2Col)
        equalsLabel = QLabel("=", group)
        equalsLabel.setAlignment(Qt.AlignHCenter)
        outLabel = QLabel(outText, group)
        outRowInput = QComboBox(group)
        outRow, outCol = decode_pos(outCell)
        outRowInput.addItems(rows)
        outRowInput.setCurrentIndex(outRow)
        outColInput = QComboBox(group)
        outColInput.addItems(cols)
开发者ID:death-finger,项目名称:Scripts,代码行数:70,代码来源:spreadsheet.py

示例2: MyTableWidget

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]
class MyTableWidget(QWidget):
    def __init__(self, items = [['']]):
        super(MyTableWidget, self).__init__()
        self.table = QTableWidget(len(items), len(items[0]))
        self.add_row_button = QPushButton('Add Row')
        self.add_row_button.clicked.connect(self.add_row)
        self.delete_row_button = QPushButton('Delete Row')
        self.delete_row_button.clicked.connect(self.delete_row)
        self.add_column_button = QPushButton('Add Column')
        self.add_column_button.clicked.connect(self.add_column)
        self.delete_column_button = QPushButton('Delete Column')
        self.delete_column_button.clicked.connect(self.delete_column)
        hbox = QHBoxLayout()
        hbox.setContentsMargins(0,0,0,0)
        hbox.addWidget(self.add_row_button)
        hbox.addWidget(self.delete_row_button)
        hbox.addWidget(self.add_column_button)
        hbox.addWidget(self.delete_column_button)

        self.layout = QVBoxLayout()
        self.layout.setContentsMargins(0,0,0,0)
        self.layout.addLayout(hbox)
        self.layout.addWidget(self.table)

    def add_row(self):
        self.table.setRowCount(self.table.rowCount()+1)

    def delete_row(self):
        self.table.removeRow(self.table.currentRow())

    def add_column(self):
        self.table.setColumnCount(self.table.columnCount()+1)

    def delete_column(self):
        self.table.removeColumn(self.table.currentColumn())

    def show(self):
        self.table.show()
        self.add_row_button.show()
        self.delete_row_button.show()
        self.add_column_button.show()
        self.delete_column_button.show()

    def hide(self):
        self.table.hide()
        self.add_row_button.hide()
        self.delete_row_button.hide()
        self.add_column_button.hide()
        self.delete_column_button.hide()

    def set_values(self, items):
        self.table.setRowCount(len(items))
        self.table.setColumnCount(len(items[0]))
        for i, row in enumerate(items):
            for j, value in enumerate(row):
                item = QTableWidgetItem(value)
                self.table.setItem(i, j, item)

    def get_values(self):
        rows = self.table.rowCount()
        cols = self.table.columnCount()
        table = []
        for i in range(rows):
            row = []
            for j in range(cols):
                row.append(self.table.item(i, j).text())
            table.append(row)

        return table
开发者ID:bobev18,项目名称:stujeditor,代码行数:71,代码来源:gui_classes.py

示例3: RowControlTableWidget

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]
class RowControlTableWidget(QWidget):
    def __init__(self, items = [('col1_name', 'default text'), ('col2_name', ['dfeault', 'combo', 'elements'])]):
        super(RowControlTableWidget, self).__init__()
        self.ordered_column_keys = [ z[0] for z in items ]
        self.default_row = { z[0]:z[1] for z in items }
        self.table = QTableWidget(1, len(items))
        self.table.setHorizontalHeaderLabels(self.ordered_column_keys)
        self.add_row_button = QPushButton('Add Row')
        self.add_row_button.clicked.connect(self.add_row)
        self.delete_row_button = QPushButton('Delete Row')
        self.delete_row_button.clicked.connect(self.delete_row)
        hbox = QHBoxLayout()
        hbox.setContentsMargins(0,0,0,0)
        hbox.addWidget(self.add_row_button)
        hbox.addWidget(self.delete_row_button)

        self.layout = QVBoxLayout()
        self.layout.setContentsMargins(0,0,0,0)
        self.layout.addLayout(hbox)
        self.layout.addWidget(self.table)

    def reset_row_template(self, items = [('col1_name', 'default text'), ('col2_name', ['dfeault', 'combo', 'elements'])]):
        # use to (re)set the values of the drop down elements inside the table cells
        self.ordered_column_keys = [ z[0] for z in items ]
        self.default_row = { z[0]:z[1] for z in items }

    def add_row(self):
        new_row_number = self.table.rowCount()
        self.table.setRowCount(self.table.rowCount()+1)

        for column, key in enumerate(self.ordered_column_keys):
                value = self.default_row[key]
                # print(value, type(value))
                if isinstance(value, str):
                    item = QTableWidgetItem(value)
                    self.table.setItem(new_row_number, column, item)
                elif isinstance(value, list):
                    combo_box = QComboBox()
                    combo_box.insertItems(0, value)
                    # combo_box.setCurrentText(value[0])
                    self.table.setCellWidget(new_row_number, column, combo_box)
                else:
                    message = 'Table cells are expected to be either Dict (added asQComboBox via setCellWidget) or String (added as QTableWidgetItem). You have type ' + str(type(value))
                    message += ' at position ' + str(new_row_number) + ', ' + str(column)
                    raise CellObjectException(message)

    def delete_row(self):
        self.table.removeRow(self.table.currentRow())

    def show(self):
        self.table.show()
        self.add_row_button.show()
        self.delete_row_button.show()

    def hide(self):
        self.table.hide()
        self.add_row_button.hide()
        self.delete_row_button.hide()

    def set_text(self, items):
        # where items should be list of lists of objects that can be either dict (loads as QComboBox) or string (used in setItem)
        # print('siphon itmes', items)
        self.table.setRowCount(len(items))
        self.table.setColumnCount(len(items[0]))
        for i, row in enumerate(items):
            # print('siphon row', row)
            for j, value in enumerate(row):
                if isinstance(value, str):
                    item = QTableWidgetItem(value)
                    self.table.setItem(i, j, item)
                elif isinstance(value, dict):
                    combo_box = QComboBox()
                    dict_keys = list(value.keys())
                    selected = dict_keys[0]
                    if isinstance(value[selected], dict):
                        combo_box.insertItems(0, list(value[selected].values()))
                    else:
                        combo_box.insertItems(0, value[selected])
                    combo_box.setCurrentText(selected)
                    self.table.setCellWidget(i, j, combo_box)
                else:
                    message = 'Table cells are expected to be either Dict (added asQComboBox via setCellWidget) or String (added as QTableWidgetItem). You have type ' + str(type(value))
                    message += ' at position ' + str(i) + ', ' + str(j)
                    raise CellObjectException(message)

    def get_values(self):
        table = []
        for i in range(self.table.rowCount()):
            row = []
            for j in range(self.table.columnCount()):
                try:
                    row.append(self.table.item(i, j).text())
                except AttributeError:
                    row.append(self.table.cellWidget(i, j).currentText())
            table.append(row)
        return table
开发者ID:bobev18,项目名称:stujeditor,代码行数:98,代码来源:gui_classes.py

示例4: HistoryCertification

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]

#.........这里部分代码省略.........
            item = self.tableWidget.item(linha, 1)
            item.setText(cada_equipamento.linha_servico)

            item = self.tableWidget.item(linha, 2)
            item.setText(str(cada_equipamento.equipamento))

            item = self.tableWidget.item(linha, 3)
            item.setText(str(cada_equipamento.data_evento.date().strftime('%d-%m-%Y')))

            item = self.tableWidget.item(linha, 4)
            item.setText(str(cada_equipamento.evento))

            item = self.tableWidget.item(linha, 5)
            item.setText(str(cada_equipamento.numero_documento))

            linha+=1

    def ver_equipamento(self):
        print("Entrei aqui")
        tela_ver_equipamento = HistoryView()
        linha = self.tableWidget.currentRow()
        numero_documento = self.tableWidget.item(linha,5).text()
        tela_ver_equipamento.carrega_dados(numero_documento)
        tela_ver_equipamento.exec()

    def gerar_export_excel(self):
        # Leitura da TableWidget da tela do programa
        if self.tableWidget.rowCount()== 0:
            QMessageBox.about(self,'Warning','Tabela de dados inexistente')
            return  None
        lista_tabela = list()
        cabecalhos = list()
        index_coluna = 0
        while index_coluna < self.tableWidget.columnCount():
            cabecalhos.append(self.tableWidget.horizontalHeaderItem(index_coluna).text())
            index_coluna = index_coluna + 1
        lista_tabela.append(cabecalhos)
        index_linha = 0
        while index_linha < self.tableWidget.rowCount():
            index_coluna = 0
            linha = list()
            while index_coluna < self.tableWidget.columnCount():
                if self.tableWidget.item(index_linha,index_coluna) != None:
                    linha.append(self.tableWidget.item(index_linha,index_coluna).text())
                else:
                    linha.append('-')
                index_coluna += 1
            lista_tabela.append(linha)
            index_linha += 1
        exportar = ExcelExport()
        exportar.exportacao(lista_tabela)
        QMessageBox.about(self,'Message','Arquivo exportado com sucesso')

    def gerar_relatorio_historico(self):
        if len(self.filtro_tabela) == 0 :
            QMessageBox.about(self,'Warning','Dados insuficientes para gerar relatório!')
            return None

        if len(self.filtro_tabela) > 0 :

            # Análise do Período
            periodo = "Período de Análise:  "" De "+self.dateEdit.text()+" até "+self.dateEdit_2.text()+""

            # Faz um sumário dos eventos realizados durante a data selecionada

            # Montagem do Relatório
开发者ID:losimonassi,项目名称:Searchfication,代码行数:70,代码来源:File_History_Certification.py

示例5: InputTableModel

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]
class InputTableModel(QDialog):
    def __init__(self, title, numVar, numCons, typeVar, objCrit, parent=None):
        super(InputTableModel, self).__init__(parent)
        self.problem = None
        self.problemTitle = title
        self.numVariables = numVar
        self.numConstraints = numCons
        self.objCriterion = objCrit
        self.typeVariable = typeVar
        self.tableModel = QTableWidget(self.numConstraints+1, self.numVariables+2)
        self.tableModel.setItemDelegate(Delegate(self))

        listVariables = []
        for m in range(self.numVariables):
            listVariables.append("X"+str(m))

        listVariables.extend(["Direction","R.H.S"])

        #Generar Filas
        listConstraints = ["Objetive"]
        for m in range(self.numConstraints):
            listConstraints.append("C"+str(m))
            combo = QComboBox()
            combo.addItem('<')
            combo.addItem('<=')
            combo.addItem('=')
            combo.addItem('>=')
            combo.addItem('>')
            self.tableModel.setCellWidget(m+1, self.numVariables, combo)

        #listConstraints.extend(["LowerBound","UpperBound", "VariableType"])

        self.tableModel.setCellWidget(0, self.numVariables, QLabel(""))

        self.tableModel.setHorizontalHeaderLabels(listVariables)
        self.tableModel.setVerticalHeaderLabels(listConstraints)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.verify)
        buttonBox.rejected.connect(self.reject)

        f = "Problem Title: "
        if self.objCriterion == True:
            f = f + self.problemTitle + " - Objetive: Maximitation"
        else:
            f = f + self.problemTitle + " - Objetive: Minimization"
        t = QLabel(f)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(t)
        mainLayout.addWidget(self.tableModel)
        mainLayout.addWidget(buttonBox)

        width = self.tableModel.columnWidth(1)*(self.tableModel.columnCount()+1)
        height = self.tableModel.rowHeight(0)*(self.tableModel.rowCount()+4)

        self.resize(QSize(width, height))
        self.setWindowTitle("Input Problem Model")
        self.setLayout(mainLayout)

    def verify(self):
        #Matix Values
        matrix = []
        matrixGraph = []
        for f in range(self.tableModel.rowCount()):
            row = []
            for c in range(self.tableModel.columnCount()):
                if c == self.numVariables:
                    item = self.tableModel.cellWidget(f,c)
                    if type(item) == QComboBox:
			            row.append(item.currentText())
                else:
                    item = self.tableModel.item(f,c)
                    if item == None:
                        row.append(0)
                    else:
                        row.append(float(item.text()))
            if f == 0:
                row.pop(-1)
            matrix.append(row)
        flag = False
        for s in range(len(matrix[0])):
            if matrix[0][s] == 0:
                flag = True
        
        if flag == False:
            #Title and Criterion
            if self.objCriterion:
                self.problem = LpProblem(self.problemTitle, LpMaximize)
            else:
                self.problem = LpProblem(self.problemTitle, LpMinimize)
    
            #Non Negative Continuous
            if self.typeVariable == 1:
                x = LpVariable.matrix("x", list(range(self.numVariables)), 0, None)
                print "Non Negative Continuous"
            #Non Negative Integer
            elif self.typeVariable == 2:
                x = LpVariable.matrix("x", list(range(self.numVariables)), 0, None
                                        , LpInteger)
#.........这里部分代码省略.........
开发者ID:bruino,项目名称:pulppy,代码行数:103,代码来源:pulppy.py

示例6: Table

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]
class Table(QWidget):


    def __init__(self):
        super().__init__()

        self.lay = QHBoxLayout(self)
        self.tableWidget = QTableWidget(self)

        self.lay.addWidget(self.tableWidget)

        for i in range(2):
            self.tableWidget.insertRow(i)
            self.tableWidget.insertColumn(i)

        for i in range(2):
            for j in range(2):
                self.tableWidget.setItem(i, j, QTableWidgetItem(''))

        # self.tableWidget.setItem(int row, int column, QTableWidgetItem *item)
        # self.tableWidget.takeItem(int row, int column)

        self.load()

    def load(self):
        if os.path.exists('temp.xls'):
            # открываем файл
            rb = xlrd.open_workbook('temp.xls', formatting_info=True)

            # выбираем активный лист
            sheet = rb.sheet_by_index(0)

            # получаем список значений из всех записей
            # vals = [sheet.row_values(rownum) for rownum in range(sheet.nrows)]

            rows = self.tableWidget.rowCount()
            cols = self.tableWidget.columnCount()

            print(':', rows, cols)

            for rownum in range(rows):
                row = sheet.row_values(rownum)
                for col in range(cols):
                    print(rownum, col)
                    item = self.tableWidget.item(rownum, col)
                    item.setText(row[col])

    def save(self):
        wb = xlwt.Workbook()
        ws = wb.add_sheet('Test')

        rows = self.tableWidget.rowCount()
        cols = self.tableWidget.columnCount()

        for row in range(rows):
            for col in range(cols):
                item = self.tableWidget.item(row, col)
                ws.write(row, col, item.text())

        # сохраняем рабочую книгу
        wb.save('temp.xls')

    def closeEvent(self, event):
        print('saving...')
        self.save()
        return super().closeEvent(event)
开发者ID:aaveter,项目名称:curs_2016_b,代码行数:68,代码来源:table.py

示例7: PlanningCertification

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]

#.........这里部分代码省略.........

            linha+=1

        self.tableWidget.setSortingEnabled(False)

    def gerar_relatorio_planejamento(self):
        if len(self.filtro_tabela) == 0 :
            QMessageBox.about(self,'Warning','Dados insuficientes para gerar relatório!')
            return None
        if len(self.filtro_tabela) > 0 :

            # Análise do Período
            periodo = "Período de Análise:  "" De "+self.dateEdit.text()+" até "+self.dateEdit_2.text()+""
            # Análise Filtro Manutenção
            planejameto_niveis_manutencao = str()
            if self.checkBox_n1_2.isChecked(): planejameto_niveis_manutencao = " N1 "
            if self.checkBox_n2_2.isChecked(): planejameto_niveis_manutencao = " N2 "
            if self.checkBox_n3_2.isChecked(): planejameto_niveis_manutencao = " N3 "
            if self.checkBox_n1_2.isChecked() and self.checkBox_n2_2.isChecked() : planejameto_niveis_manutencao = " N1 , N2 "
            if self.checkBox_n1_2.isChecked() and self.checkBox_n3_2.isChecked() : planejameto_niveis_manutencao = " N1 , N3 "
            if self.checkBox_n2_2.isChecked() and self.checkBox_n3_2.isChecked() : planejameto_niveis_manutencao = " N2 , N3 "
            if self.checkBox_n1_2.isChecked() and self.checkBox_n2_2.isChecked() and self.checkBox_n3_2.isChecked() : planejameto_niveis_manutencao = "N1,  N2, N3 "

            # Análise Filtro Manutenção Vencidas
            planejameto_niveis_manutencao_vencida = str()
            if self.checkBox_n1_vencida.isChecked(): planejameto_niveis_manutencao_vencida = " Inclui na lista os equipamentos que estão com a manutenção N1 vencida"
            if self.checkBox_n2_vencida.isChecked(): planejameto_niveis_manutencao_vencida = " Inclui na lista os equipamentos que estão com a manutenção N2 vencida"
            if self.checkBox_n3_vencida.isChecked(): planejameto_niveis_manutencao_vencida = " Inclui na lista os equipamentos que estão com a manutenção N3 vencida"
            if self.checkBox_n1_vencida.isChecked() and self.checkBox_n2_vencida.isChecked() : planejameto_niveis_manutencao_vencida = "Inclui na lista os equipamentos que estão com a manutenção(s) N1 e N2 vencida(s)  "
            if self.checkBox_n1_vencida.isChecked() and self.checkBox_n3_vencida.isChecked() : planejameto_niveis_manutencao_vencida = "Inclui na lista os equipamentos que estão com a manutenção(s) N1 e N3 vencida(s)  "
            if self.checkBox_n2_vencida.isChecked() and self.checkBox_n3_vencida.isChecked() : planejameto_niveis_manutencao_vencida = "Inclui na lista os equipamentos que estão com a manutenção(s) N2 e N3 vencida(s)  "
            if self.checkBox_n1_vencida.isChecked() and self.checkBox_n2_vencida.isChecked() and self.checkBox_n3_vencida.isChecked() : planejameto_niveis_manutencao_vencida = "Inclui na lista os equipamentos que estão com a manutenção(s) N1, N2 e N3 vencida(s)  "
            if self.checkBox_n1_vencida.isChecked()==False and self.checkBox_n2_vencida.isChecked()==False and self.checkBox_n3_vencida.isChecked()==False : planejameto_niveis_manutencao_vencida = "Não estão incluidos os equipamentos com manutenções vencidas "


            # Montagem do Relatório
            relatorio_planejamento = Report('relatorio_planejamento.pdf')

            relatorio_planejamento.setar_primeira_pagina('Relatório de Certificação', 'Planejamento')

            relatorio_planejamento.setagem_cabecalho('Certificação - Planejamento')

            relatorio_planejamento.adicionar_topico("1 - Filtro - Previsão de Próximas Manutenções")

            relatorio_planejamento.adicionar_paragrafo(periodo)

            relatorio_planejamento.adicionar_paragrafo(" Equipamentos que irão vencer no período os níveis de manutenção "+planejameto_niveis_manutencao+"")

            relatorio_planejamento.adicionar_paragrafo(planejameto_niveis_manutencao_vencida)


            # Leitura da TableWidget da tela do programa
            index_linha = 0
            cabecalhos = ['Trace Number', 'Equip.', 'Próx. N1', 'Próx. N2', 'Próx. N3', 'DNV','Próx. TC', 'Próx. Insp. Vis', 'Próx. Recer']
            lista_tabela = list()
            lista_tabela.append(cabecalhos)
            while index_linha < self.tableWidget.rowCount():
                index_coluna = 0
                linha = list()
                while index_coluna < self.tableWidget.columnCount():
                    if self.tableWidget.item(index_linha,index_coluna) != None:
                        linha.append(self.tableWidget.item(index_linha,index_coluna).text())
                    else:
                        linha.append('-')
                    index_coluna += 1
                lista_tabela.append(linha)
                index_linha += 1


            relatorio_planejamento.adicionar_tabela(lista_tabela)
            relatorio_planejamento.criar_relatorio_pdf()

    def gerar_export_excel(self):
        # Leitura da TableWidget da tela do programa
            if self.tableWidget.rowCount()== 0:
                QMessageBox.about(self,'Warning','Tabela de dados inexistente')
                return  None
            lista_tabela = list()
            cabecalhos = list()
            index_coluna = 0
            while index_coluna < self.tableWidget.columnCount():
                cabecalhos.append(self.tableWidget.horizontalHeaderItem(index_coluna).text())
                index_coluna = index_coluna + 1
            lista_tabela.append(cabecalhos)
            index_linha = 0
            while index_linha < self.tableWidget.rowCount():
                index_coluna = 0
                linha = list()
                while index_coluna < self.tableWidget.columnCount():
                    if self.tableWidget.item(index_linha,index_coluna) != None:
                        linha.append(self.tableWidget.item(index_linha,index_coluna).text())
                    else:
                        linha.append('-')
                    index_coluna += 1
                lista_tabela.append(linha)
                index_linha += 1
            exportar = ExcelExport()
            exportar.exportacao(lista_tabela)
            QMessageBox.about(self,'Message','Arquivo exportado com sucesso')
            return None
开发者ID:losimonassi,项目名称:Searchfication,代码行数:104,代码来源:File_Planning_Certification.py

示例8: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import columnCount [as 别名]

#.........这里部分代码省略.........
        for i in data:
            self.tableContents.append(Checker(i))

    def checkUpdateSlot(self):
        """执行更新检查"""
        self.wtime[0] = int(time.time())  # 计时
        self.statusbar.showMessage(self.tr("checking..."))
        self.progressBar.setValue(0)
        self.progressBar.show()
        self.progressVal = 0
        self.taskVal = 0

        for t in range(self.workerCount):
            t = WorkThread(self.q)  # 耗时任务需要用线程执行,再刷新进度条
            t.triggered.connect(self.updateTableSlot)
            self.workers.append(t)
            t.start()  # 执行工作线程

        # 填充队列
        for item in self.tableContents:
            self.q.put(item)

    def updateTableSlot(self, val):
        """线程通过该槽,刷新进度条,表格内容"""
        if val:
            self.taskVal += val
            self.progressVal = self.taskVal / len(self.tableContents) * 100
            self.progressBar.setValue(self.progressVal)
            self.label.setText("%s/%s" % (self.taskVal, len(self.tableContents)))
        self.tableWidget.setRowCount(len(self.tableContents))  # 行数

        for n, i in enumerate(self.tableContents):
            items = i.dump()
            for j in range(self.tableWidget.columnCount()):
                item = QTableWidgetItem(items[j])
                if j in [0, 1]:
                    item.setToolTip(item.text())
                self.tableWidget.setItem(n, j, item)
            self.setStatusColor(n)

        self.setBackgroundColor(self.bgColor)

        if self.progressVal == 100:
            self.wtime[1] = int(time.time())
            self.statusbar.showMessage(self.tr(
                "finished (work time %ds)") % (self.wtime[1] - self.wtime[0]))

    def updateTableItemSlot(self):
        """更新指定的 RPM 日期为 Release 日期"""
        rowIndex = self.tableWidget.currentRow()
        if rowIndex != -1:
            try:
                item = self.tableWidget.item(rowIndex, 4)
                self.tableWidget.item(rowIndex, 3).setText(item.text())
                self.tableContents[rowIndex].load_meta(item.text())
            except (IndexError, AttributeError):
                QMessageBox.warning(self, self.tr("Warning"), self.tr("The row is empty."))
        else:
            QMessageBox.warning(self, self.tr("Warning"), self.tr("Please select a row."))

    def editTableItemRuleSlot(self):
        """编辑列表项规则"""
        rowIndex = self.tableWidget.currentRow()
        if rowIndex != -1:
            try:
                # 父控件, 标题, 标签提示, 默认值, window flags
开发者ID:FZUG,项目名称:repo-checker,代码行数:70,代码来源:gui.py


注:本文中的PyQt5.QtWidgets.QTableWidget.columnCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。