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


Python QTableWidget.setSortingEnabled方法代码示例

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


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

示例1: skipped_gs

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
			def skipped_gs(s_list):
				"Skipped galleries"
				msg_box = QMessageBox(self)
				msg_box.setIcon(QMessageBox.Question)
				msg_box.setText('Do you want to view skipped paths?')
				msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
				msg_box.setDefaultButton(QMessageBox.No)
				if msg_box.exec() == QMessageBox.Yes:
					list_wid = QTableWidget(self)
					list_wid.setAttribute(Qt.WA_DeleteOnClose)
					list_wid.setRowCount(len(s_list))
					list_wid.setColumnCount(2)
					list_wid.setAlternatingRowColors(True)
					list_wid.setEditTriggers(list_wid.NoEditTriggers)
					list_wid.setHorizontalHeaderLabels(['Reason', 'Path'])
					list_wid.setSelectionBehavior(list_wid.SelectRows)
					list_wid.setSelectionMode(list_wid.SingleSelection)
					list_wid.setSortingEnabled(True)
					list_wid.verticalHeader().hide()
					list_wid.setAutoScroll(False)
					for x, g in enumerate(s_list):
						list_wid.setItem(x, 0, QTableWidgetItem(g[1]))
						list_wid.setItem(x, 1, QTableWidgetItem(g[0]))
					list_wid.resizeColumnsToContents()
					list_wid.setWindowTitle('{} skipped paths'.format(len(s_list)))
					list_wid.setWindowFlags(Qt.Window)
					list_wid.resize(900,400)

					list_wid.doubleClicked.connect(lambda i: utils.open_path(
						list_wid.item(i.row(), 1).text(), list_wid.item(i.row(), 1).text()))

					list_wid.show()
开发者ID:darmstard,项目名称:happypanda,代码行数:34,代码来源:app.py

示例2: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
class MainWindow(QTableWidget):
  updateSignal = pyqtSignal()
  def __init__(self, parent=None):
    super(MainWindow, self).__init__(parent)
    self.table_widget = QTableWidget()
    self.button = QPushButton('Populate')
    self.button.clicked.connect(self.populate)
    layout = QVBoxLayout()
    layout.addWidget(self.table_widget)
    layout.addWidget(self.button)
    self.setLayout(layout)
    self.updateSignal.connect(self.update_table)
    self.populate()

##-----------------------------------------    
  @pyqtSlot(int,int)
  def slotItemClicked(self,item,item2):
    QMessageBox.information(self,
                "QTableWidget Cell Click",
                "Row: "+ str(item)+" |Column: "+str(item2))    

  def populate(self):
    ncols, nrows = 2,5
    self.setWindowTitle("QTableWidget Cell Click")
    self.table_widget.setSortingEnabled(False)
    self.table_widget.setRowCount(nrows)
    self.table_widget.setColumnCount(ncols)
    for i in range(nrows):
      for j in range(ncols):
        item = QTableWidgetItem('%s%s' % (i, j))
        self.table_widget.setItem(i, j, item)
        self.updateSignal.emit()
        self.table_widget.setSortingEnabled(True)

  def update_table(self):
    self.table_widget.sortItems(1,Qt.DescendingOrder)
开发者ID:skyballoon,项目名称:PyQtTest,代码行数:38,代码来源:Copy+of+QTableWidget3.py

示例3: create_major_display_table

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
    def create_major_display_table(input_iterable,
                                   key=lambda x: x, reverse=False,
                                   headers=None, row_cell_functions=None,
                                   cutoff=0,
                                   set_text_alignment=None):
        """
        This is a general function for creating a tabular display for the
        major display.
        """

        if not input_iterable:
            print('Warning: input is empty', flush=True)
            return

        if not hasattr(input_iterable, '__iter__'):
            print('Warning: input is not an iterable', flush=True)
            return

        number_of_headers = len(headers)
        number_of_columns = len(row_cell_functions)

        if number_of_headers != number_of_columns:
            print('headers and cell functions don\'t match', flush=True)
            return

        len_input = len(input_iterable)

        table_widget = QTableWidget()
        table_widget.clear()
        table_widget.setSortingEnabled(False)

        # set up row count
        if cutoff and cutoff < len_input:
            actual_cutoff = cutoff
        else:
            actual_cutoff = len_input

        table_widget.setRowCount(actual_cutoff)

        # set up column count and table headers
        table_widget.setColumnCount(number_of_headers)
        table_widget.setHorizontalHeaderLabels(headers)

        # fill in the table
        for row, x in enumerate(double_sorted(input_iterable, key=key,
                                              reverse=reverse)):
            for col, fn in enumerate(row_cell_functions):
                cell = fn(x)

                if isinstance(cell, (int, float)):
                    # cell is numeric
                    item = QTableWidgetItem()
                    item.setData(Qt.EditRole, cell)
                else:
                    # cell is not numeric
                    item = QTableWidgetItem(cell)

                if set_text_alignment:
                    for align_col, alignment in set_text_alignment:
                        if col == align_col:
                            item.setTextAlignment(alignment)

                table_widget.setItem(row, col, item)

            if not row < actual_cutoff:
                break

        table_widget.setSortingEnabled(True)
        table_widget.resizeColumnsToContents()

        return table_widget
开发者ID:linguistica-uchicago,项目名称:lxa5,代码行数:73,代码来源:main_window.py

示例4: LabelAssistDialog

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
class LabelAssistDialog(QDialog):
    """
    A simple UI for showing bookmarks and navigating to them.

    FIXME: For now, this window is tied to a particular lane.
           If your project has more than one lane, then each one
           will have it's own bookmark window, which is kinda dumb.
    """
    def __init__(self, parent, topLevelOperatorView):
        super(LabelAssistDialog, self).__init__(parent)
        
        # Create thread router to populate table on main thread
        self.threadRouter = ThreadRouter(self)
        
        # Set object classification operator view
        self.topLevelOperatorView = topLevelOperatorView
        
        self.setWindowTitle("Label Assist")
        self.setMinimumWidth(500)
        self.setMinimumHeight(700)

        layout = QGridLayout() 
        layout.setContentsMargins(10, 10, 10, 10)
                       
        # Show variable importance table
        rows = 0
        columns = 4
        self.table = QTableWidget(rows, columns)   
        self.table.setHorizontalHeaderLabels(['Frame', 'Max Area', 'Min Area', 'Labels'])
        self.table.verticalHeader().setVisible(False)     
        
        # Select full row on-click and call capture double click
        self.table.setSelectionBehavior(QTableView.SelectRows);
        self.table.doubleClicked.connect(self._captureDoubleClick)
                
        layout.addWidget(self.table, 1, 0, 3, 2) 

        # Create progress bar
        self.progressBar = QProgressBar()
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(0)
        self.progressBar.hide()
        layout.addWidget(self.progressBar, 4, 0, 1, 2)

        # Create button to populate table
        self.computeButton = QPushButton('Compute object info')
        self.computeButton.clicked.connect(self._triggerTableUpdate)
        layout.addWidget(self.computeButton, 5, 0)
        
        # Create close button
        closeButton = QPushButton('Close')
        closeButton.clicked.connect(self.close)
        layout.addWidget(closeButton, 5, 1)
        
        # Set dialog layout
        self.setLayout(layout)       


    def _triggerTableUpdate(self):
        # Check that object area is included in selected features
        featureNames = self.topLevelOperatorView.SelectedFeatures.value
        
        if 'Standard Object Features' not in featureNames or 'Count' not in featureNames['Standard Object Features']:
            box = QMessageBox(QMessageBox.Warning,
                  'Warning',
                  'Object area is not a selected feature. Please select this feature on: \"Standard Object Features > Shape > Size in pixels\"',
                  QMessageBox.NoButton,
                  self)
            box.show()
            return 
        
        # Clear table
        self.table.clearContents()
        self.table.setRowCount(0)
        self.table.setSortingEnabled(False)
        self.progressBar.show()
        self.computeButton.setEnabled(False)

        def compute_features_for_frame(tIndex, t, features): 
            # Compute features and labels (called in parallel from request pool)
            roi = [slice(None) for i in range(len(self.topLevelOperatorView.LabelImages.meta.shape))]
            roi[tIndex] = slice(t, t+1)
            roi = tuple(roi)

            frame = self.topLevelOperatorView.SegmentationImages(roi).wait()           
            frame = frame.squeeze().astype(numpy.uint32, copy=False)
            
            # Dirty trick: We don't care what we're passing here for the 'image' parameter,
            # but vigra insists that we pass *something*, so we'll cast the label image as float32.
            features[t] = vigra.analysis.extractRegionFeatures(frame.view(numpy.float32),
                                                               frame,
                                                               ['Count'],
                                                               ignoreLabel=0)
            
        tIndex = self.topLevelOperatorView.SegmentationImages.meta.axistags.index('t')
        tMax = self.topLevelOperatorView.SegmentationImages.meta.shape[tIndex]     
        
        features = {}
        labels = {}

#.........这里部分代码省略.........
开发者ID:DerThorsten,项目名称:ilastik,代码行数:103,代码来源:objectClassificationGui.py

示例5: ErrorGroupBox

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
class ErrorGroupBox(QGroupBox):
    def __init__(self, max_deduction=0):
        def tableCellChanged(rowIdx, colIdx):
            if colIdx == 2:
                err_id = self.table.item(rowIdx, 0).text()
                new_val = self.table.item(rowIdx, colIdx).text()
                old_val = self.errors[err_id].penalty
                if new_val.isdigit():
                    self.errors[err_id].penalty = int(new_val)
                else:
                    self.table.item(rowIdx, colIdx).setText(str(old_val))

        def onMaxEditPoint(line_edit):
            self.max_deduction = int(line_edit.text())

        super().__init__()
        self.max_deduction = max_deduction

        self.table = QTableWidget()
        self.table.setRowCount(len(get_default_errors()))
        self.table.setColumnCount(4)
        self.table.setHorizontalHeaderLabels(["ID", "Description", "Penalty", "Enabled"])
        self.table.horizontalHeader().setSectionResizeMode(1)
        self.table.setShowGrid(False)
        self.table.verticalHeader().setVisible(False)
        self.table.resizeColumnsToContents()
        self.table.setSortingEnabled(False)

        self.table.cellChanged.connect(tableCellChanged)

        self.setErrors(get_default_errors())

        max_point_label = QLabel("Maximum points deduction:")

        point_validator = QIntValidator()

        self.max_point_edit = QLineEdit()
        self.max_point_edit.setMaximumWidth(50)
        self.max_point_edit.setText("0")
        self.max_point_edit.setValidator(point_validator)
        self.max_point_edit.editingFinished.connect(lambda: onEditMax(self.max_point_edit))

        gb_grid = QGridLayout()

        gb_grid.addWidget(self.table, 0, 0, 4, 6)
        gb_grid.addWidget(max_point_label, 5, 4, 1, 1)
        gb_grid.addWidget(self.max_point_edit, 5, 5, 1, 1)

        self.setLayout(gb_grid)
        self.setTitle("Errors")
        self.setCheckable(True)
        self.setChecked(False)

    def chkboxClicked(self, err, state):
        self.errors[err.id].is_enabled = state is Qt.Checked

    def setErrors(self, errors):
        self.errors = errors

        for idx, err_key in enumerate(sorted(self.errors)):
            err = self.errors[err_key]
            id_item = QTableWidgetItem(err.id)
            id_item.setFlags(Qt.ItemIsEnabled)

            desc_item = QTableWidgetItem(err.check)
            desc_item.setFlags(Qt.ItemIsEnabled)

            penalty_item = QTableWidgetItem(str(err.penalty))
            penalty_item.setTextAlignment(Qt.AlignCenter)

            cell_widget = QWidget()
            chk_box = QCheckBox()
            if err.is_enabled:
                chk_box.setCheckState(Qt.Checked)
            else:
                chk_box.setCheckState(Qt.Unchecked)
            chk_box.stateChanged.connect(lambda state, err=err: self.chkboxClicked(err, state))
            layout = QHBoxLayout(cell_widget)
            layout.addWidget(chk_box)
            layout.setAlignment(Qt.AlignCenter)
            cell_widget.setLayout(layout)

            self.table.setItem(idx, 0, id_item)
            self.table.setItem(idx, 1, desc_item)
            self.table.setItem(idx, 2, penalty_item)
            self.table.setCellWidget(idx, 3, cell_widget)
开发者ID:faouellet,项目名称:CorrectUS,代码行数:88,代码来源:errorgb.py

示例6: Viewer

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
class Viewer(QMainWindow):
    """The main window for the application."""

    def __init__(self, stats, mode, difficulties, theme):
        """Initializes basic information about the Viewer class."""
        super().__init__()

        ### Initialize parameters passed from smtracker.py
        self.stats = stats                 # XML tree
        self.mode = mode                   # Gamemode
        self.difficulties = difficulties   # Tracked difficulties

        ### Initialize interface options
        self.icons_enabled = True          # Icons

        ### Create an empty table
        if self.stats is not None:
            song_count = len(self.stats.find("SongScores"))
            self.table = QTableWidget(song_count, len(self.difficulties) + 2)
        else:
            self.table = QTableWidget(0, len(self.difficulties) + 2)

        # Set some basic table attributes
        self.table.setIconSize(QSize(32, 32))
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table.setSelectionMode(QAbstractItemView.NoSelection)

        table_header = ["Group", "Title"]
        table_header.extend(self.difficulties)

        # Sets the header cells
        for head in table_header:
            where = table_header.index(head)
            headeritem = QTableWidgetItem()
            headeritem.setText(head)
            self.table.setHorizontalHeaderItem(where, headeritem)

        self.theme = theme
        self.init_ui()


    def init_table(self):
        """Generates a table with the song scores."""

        # Prepare table for inserting items
        self.table.clearContents()
        self.table.setSortingEnabled(False)

        # Current table row
        current_row = 0
        for song in self.stats.find("SongScores"):
            # Current table row
            current_column = 0

            # Get the song's group and title
            # location[0] should always be "Songs"
            location = song.attrib['Dir'].split('/')

            # Create group cell
            group = QTableWidgetItem(location[1])
            self.table.setItem(current_row, current_column, group)
            current_column = current_column + 1

            # Create title cell
            title = QTableWidgetItem(location[2])
            self.table.setItem(current_row, current_column, title)
            current_column = current_column + 1

            # step_counter will be used for traversing the scores in a song
            step_counter = 0
            for diff in self.difficulties:
                try:
                    if (song[step_counter].attrib['Difficulty'] == diff and
                        song[step_counter].attrib['StepsType'] == self.mode):
                        try:
                            grade = smformat.highscore_grade(song[step_counter], self.theme)
                            percent = float(parse.highscore_stat(song[step_counter], "PercentDP")) * 100
                            if self.theme == "sm5" and self.icons_enabled is True:
                                cell = QTableWidgetItem('{:.2f}%'.format(percent))
                                cell.setIcon(QIcon(smtracker.__path__[0] + '/images/' + grade + '.png'))
                            else:
                                cell = QTableWidgetItem('{} ({:.2f}%)'.format(grade, percent))

                            # Get the timings for our song
                            timings = parse.highscore_timings(song[step_counter])

                            # TODO: Figure out if there's a cleaner way of
                            # doing this
                            tooltip = """Marvelous: {}
Perfect: {}
Great: {}
Good: {}
Boo: {}
Miss: {}
-----
Modifiers: {}
-----
SN2 Score: {}
DDRA Score: {}
IIDX EX Score: {}""".format(timings['W1'], timings['W2'], timings['W3'], timings['W4'],
#.........这里部分代码省略.........
开发者ID:japareaggae,项目名称:smtracker,代码行数:103,代码来源:qt.py

示例7: __init__

# 需要导入模块: from PyQt5.QtWidgets import QTableWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTableWidget import setSortingEnabled [as 别名]
    def __init__(self, named_importances, *args, **kwargs):
        super(VariableImportanceDialog, self).__init__(*args, **kwargs)
        self.setWindowTitle("Variable Importance Table")
        self.setMinimumWidth(700)
        self.setMinimumHeight(800)

        layout = QGridLayout() 
        layout.setContentsMargins(10, 10, 10, 10)
               
        if named_importances:
            # Show variable importance table
            rows = len(list(named_importances.items()))
            columns = 5
            table = QTableWidget(rows, columns)   
            table.setHorizontalHeaderLabels(['Variable Name', 'Class #0', 'Class #1', 'Overall', 'Gini'])
            table.verticalHeader().setVisible(False)      
            
            importances_mins = list(map(min, list(zip(*list(named_importances.values())))))
            importances_maxs = list(map(max, list(zip(*list(named_importances.values())))))
            
            for i, (variable, importances) in enumerate(named_importances.items()):     
                # Remove non-ASCII characters to get rid of the sigma character in the variable names.
                variable = re.sub(r'[^\x00-\x7F]+','s', variable)
                
                item = QTableWidgetItem(variable)
                item.setFlags( Qt.ItemIsSelectable |  Qt.ItemIsEnabled )
                table.setItem(i, 0, item)

                for j, importance in enumerate(importances):
                    # Get color based on the importance value
                    val = importances[j]
                    imin = importances_mins[j]
                    imax = importances_maxs[j]
                    range = importances_maxs[j] - importances_mins[j]
                    color = int( 255 - old_div(( (val-imin) * 200), range) )    

                    # Load items as strings
                    item = QTableWidgetItemWithFloatSorting(str("{: .05f}".format(importance)))
                    item.setFlags( Qt.ItemIsSelectable |  Qt.ItemIsEnabled )
                    item.setBackground(QColor(color,255,color))
                    table.setItem(i, j+1, item)
                    
            table.resizeColumnsToContents()  
            
            table.setSortingEnabled(True)
            table.sortByColumn(3, Qt.DescendingOrder)  # Sort by overall importance

            layout.addWidget(table, 1, 0, 3, 2)  
            
        else:
            # Classifier is not trained. Show warning message.
            msg = ('To enable this feature, you must choose the following classifier type via the menu Advanced > Classifier:\n\n'
                   '"Parallel Random Forest Classifier with Variable Importance (VIGRA)"\n\n'
                   '...and then RETRAIN your classifier (press "Live Update").')
            warningLabel = QLabel(msg)
            warningLabel.setAlignment(Qt.AlignCenter)
            warningLabel.setWordWrap(True) 
            layout.addWidget(warningLabel, 3, 0, 1 ,2)

        # Create and add close button
        closeButton = QPushButton("Close")
        closeButton.clicked.connect(self.close)
        layout.addWidget(closeButton, 4, 1)
        
        self.setLayout(layout)
开发者ID:ilastik,项目名称:ilastik,代码行数:67,代码来源:variableImportanceDialog.py

示例8: DPlayerUI

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

#.........这里部分代码省略.........
    def addFiles(self):
        """Choose files (*.mp3) to add to the playlist."""
        fileNames, _ = QFileDialog.getOpenFileNames(
            self, 'Add songs', filter='Music (*.mp3 *.ogg *.flac *wav)')
        self.playerCore.add(fileNames)
        self.addClicked(fileNames)

    def addFolder(self):
        """Choose folder to add to the playlist."""
        directory = QFileDialog.getExistingDirectory(self, 'Add a folder')
        self.getFromDir(directory)

    def getFromDir(self, directory):
        """Extract files from directory and add them to the playlist."""
        if not directory:
            return

        dirContent = os.listdir(directory)
        fileNames = []
        for file in dirContent:
            path = '{}/{}'.format(directory, file)
            if os.path.isfile(path) and \
                    path[len(path) - 4:] in ['.mp3', '.ogg', 'flac', '.wav']:
                fileNames.append(path)
            elif os.path.isdir(path):
                self.getFromDir(path)
        self.playerCore.add(fileNames)
        self.addClicked(fileNames)

    def addClicked(self, fileNames):
        """Fill the playlist with fileNames' info."""
        if fileNames is None:
            return
        self.playlistTable.setSortingEnabled(False)
        songsToAdd = len(fileNames)
        for name, row in zip(fileNames, range(songsToAdd)):
            currentRow = row + self.playlist.mediaCount() - songsToAdd
            self.playlistTable.insertRow(currentRow)

            artist = self.playerCore.getArtist(name)[0]
            title = self.playerCore.getTitle(name)[0]
            album = self.playerCore.getAlbum(name)[0]
            seconds = self.playerCore.getDuration(name)
            duration = QTime(0, seconds // 60, seconds % 60)
            duration = duration.toString('mm:ss')

            rowInfo = [artist, title, album, duration]
            for info, index in zip(rowInfo, range(4)):
                cell = QTableWidgetItem(info)
                self.playlistTable.setItem(currentRow, index, cell)
                font = QFont(info, weight=QFont.Normal)
                cell.setFont(font)
                cell.setTextAlignment(Qt.AlignCenter)
        self.playlistTable.setSortingEnabled(True)

        for index in range(4):
            self.playlistTable.resizeColumnToContents(index)

    def initVolumeSlider(self):
        """Initialize volume slider."""
        self.volumeSlider = QSlider(Qt.Vertical, self)
        self.volumeSlider.setRange(0, 100)
        self.currentVolume = 70
        self.volumeSlider.setValue(self.currentVolume)
        self.volumeSlider.setToolTip('volume: {}'.format(self.currentVolume))
        self.volumeSlider.valueChanged[int].connect(self.volumeChanged)
开发者ID:DanislavKirov,项目名称:DPlayer,代码行数:70,代码来源:ui.py

示例9: PlanningCertification

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

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

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

            item = self.tableWidget.item(linha, 6)
            if cada_equipamento.proximo_teste_carga != None:
                item.setText(str(cada_equipamento.proximo_teste_carga.date().strftime('%d-%m-%Y')))
                if linha % 2 == 0:
                    if cada_equipamento.proximo_teste_carga.date() < datetime.date.today():   self.tableWidget.item(linha, 6).setBackground(QtGui.QColor(216,31,42))
                else:
                    if cada_equipamento.proximo_teste_carga.date() < datetime.date.today():   self.tableWidget.item(linha, 6).setBackground(QtGui.QColor(161,40,48))
            else: item.setText("-")

            item = self.tableWidget.item(linha, 7)
            if cada_equipamento.proxima_inspecao_visual != None:
                item.setText(str(cada_equipamento.proxima_inspecao_visual.date().strftime('%d-%m-%Y')))
                if linha % 2 == 0:
                    if cada_equipamento.proxima_inspecao_visual.date() < datetime.date.today():   self.tableWidget.item(linha, 7).setBackground(QtGui.QColor(216,31,42))
                else:
                    if cada_equipamento.proxima_inspecao_visual.date() < datetime.date.today():   self.tableWidget.item(linha, 7).setBackground(QtGui.QColor(161,40,48))
            else: item.setText("-")

            item = self.tableWidget.item(linha, 8)
            if cada_equipamento.proxima_recertificacao_dnv != None:
                item.setText(str(cada_equipamento.proxima_recertificacao_dnv.date().strftime('%d-%m-%Y')))
                if linha % 2 == 0:
                    if cada_equipamento.proxima_recertificacao_dnv.date() < datetime.date.today():   self.tableWidget.item(linha, 8).setBackground(QtGui.QColor(216,31,42))
                else:
                    if cada_equipamento.proxima_recertificacao_dnv.date() < datetime.date.today():   self.tableWidget.item(linha, 8).setBackground(QtGui.QColor(161,40,48))
            else: item.setText("-")

            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
开发者ID:losimonassi,项目名称:Searchfication,代码行数:70,代码来源:File_Planning_Certification.py


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