コード例 #1
0
ファイル: view.py プロジェクト: yutiansut/mantid
    def _make_table_widget(self):
        """
        Make a table showing the matplotlib figure number of the
        plots, the name with close and edit buttons, and a hidden
        column for sorting with the last actuve order
        :return: A QTableWidget object which will contain plot widgets
        """
        table_widget = QTableWidget(0, 3, self)
        table_widget.setHorizontalHeaderLabels(['No.', 'Plot Name', 'Last Active Order (hidden)'])

        table_widget.verticalHeader().setVisible(False)

        # Fix the size of 'No.' and let 'Plot Name' fill the space
        top_header = table_widget.horizontalHeader()

        table_widget.horizontalHeaderItem(Column.Number).setToolTip('This is the matplotlib figure number.\n\nFrom a '
                                                                    'script use plt.figure(N), where N is this figure '
                                                                    'number, to get a handle to the plot.')

        table_widget.horizontalHeaderItem(Column.Name).setToolTip('The plot name, also used  as the file name when '
                                                                  'saving multiple plots.')

        table_widget.setSelectionBehavior(QAbstractItemView.SelectRows)
        table_widget.setSelectionMode(QAbstractItemView.ExtendedSelection)
        table_widget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table_widget.sortItems(Column.Number, Qt.AscendingOrder)
        table_widget.setSortingEnabled(True)

        table_widget.horizontalHeader().sectionClicked.connect(self.update_sort_menu_selection)

        if not DEBUG_MODE:
            table_widget.setColumnHidden(Column.LastActive, True)

        top_header.resizeSection(Column.Number, top_header.sectionSizeHint(Column.Number))
        top_header.setSectionResizeMode(Column.Name, QHeaderView.Stretch)

        return table_widget
コード例 #2
0
ファイル: view.py プロジェクト: mantidproject/mantid
    def _make_table_widget(self):
        """
        Make a table showing the matplotlib figure number of the
        plots, the name with close and edit buttons, and a hidden
        column for sorting with the last actuve order
        :return: A QTableWidget object which will contain plot widgets
        """
        table_widget = QTableWidget(0, 3, self)
        table_widget.setHorizontalHeaderLabels(['No.', 'Plot Name', 'Last Active Order (hidden)'])

        table_widget.verticalHeader().setVisible(False)

        # Fix the size of 'No.' and let 'Plot Name' fill the space
        top_header = table_widget.horizontalHeader()

        table_widget.horizontalHeaderItem(Column.Number).setToolTip('This is the matplotlib figure number.\n\nFrom a '
                                                                    'script use plt.figure(N), where N is this figure '
                                                                    'number, to get a handle to the plot.')

        table_widget.horizontalHeaderItem(Column.Name).setToolTip('The plot name, also used  as the file name when '
                                                                  'saving multiple plots.')

        table_widget.setSelectionBehavior(QAbstractItemView.SelectRows)
        table_widget.setSelectionMode(QAbstractItemView.ExtendedSelection)
        table_widget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        table_widget.sortItems(Column.Number, Qt.AscendingOrder)
        table_widget.setSortingEnabled(True)

        table_widget.horizontalHeader().sectionClicked.connect(self.update_sort_menu_selection)

        if not DEBUG_MODE:
            table_widget.setColumnHidden(Column.LastActive, True)

        top_header.resizeSection(Column.Number, top_header.sectionSizeHint(Column.Number))
        top_header.setSectionResizeMode(Column.Name, QHeaderView.Stretch)

        return table_widget