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


Python QHeaderView.ResizeToContents方法代码示例

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


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

示例1: init_logs

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def init_logs(self):
        self.logTableWidget.setAlternatingRowColors(True)
        header = self.logTableWidget.horizontalHeader()
        header.setVisible(True)
        [header.setSectionResizeMode(i, QHeaderView.ResizeToContents) for i in range(5)]
        header.setSectionResizeMode(3, QHeaderView.Stretch)

        self.logTableWidget.setSelectionBehavior(QTableView.SelectRows)
        self.logTableWidget.setEditTriggers(QTableView.NoEditTriggers)

        event_logs = [s for s in EventLogModel.select().order_by(EventLogModel.start_time.desc())]

        for row, log_line in enumerate(event_logs):
            self.logTableWidget.insertRow(row)
            formatted_time = log_line.start_time.strftime('%Y-%m-%d %H:%M')
            self.logTableWidget.setItem(row, 0, QTableWidgetItem(formatted_time))
            self.logTableWidget.setItem(row, 1, QTableWidgetItem(log_line.category))
            self.logTableWidget.setItem(row, 2, QTableWidgetItem(log_line.subcommand))
            self.logTableWidget.setItem(row, 3, QTableWidgetItem(log_line.repo_url))
            self.logTableWidget.setItem(row, 4, QTableWidgetItem(str(log_line.returncode)))
        self.logTableWidget.setRowCount(len(event_logs))
        self._draw_next_scheduled_backup() 
开发者ID:borgbase,项目名称:vorta,代码行数:24,代码来源:schedule_tab.py

示例2: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, fs_data, archive_newer, archive_older):
        super().__init__()
        self.setupUi(self)

        files_with_attributes, nested_file_list = parse_diff_lines(fs_data.split('\n'))
        model = DiffTree(files_with_attributes, nested_file_list)

        view = self.treeView
        view.setAlternatingRowColors(True)
        view.setUniformRowHeights(True)  # Allows for scrolling optimizations.
        view.setModel(model)
        header = view.header()
        header.setStretchLastSection(False)
        header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(0, QHeaderView.Stretch)

        self.archiveNameLabel_1.setText(f'{archive_newer.name}')
        self.archiveNameLabel_2.setText(f'{archive_older.name}')
        self.okButton.clicked.connect(self.accept) 
开发者ID:borgbase,项目名称:vorta,代码行数:22,代码来源:diff_result.py

示例3: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, *args, **kwargs):
        QWidget.__init__(self, *args, **kwargs)
        self.request = None
        self.setLayout(QVBoxLayout())
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.infotable = QTableWidget()
        self.infotable.setColumnCount(2)

        self.infotable.verticalHeader().hide()
        self.infotable.horizontalHeader().hide()
        self.infotable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        self.infotable.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        self.infotable.horizontalHeader().setStretchLastSection(True)

        self.layout().addWidget(self.infotable) 
开发者ID:roglew,项目名称:guppy-proxy,代码行数:18,代码来源:reqview.py

示例4: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, parent):
        super(CentralWidget, self).__init__(parent)
        logger.debug("CentralWidget instance created.")
        self.setupUi(self)
        self.dirty = False
        self.configManager = None
        self.recorder = iomediator.Recorder(self.scriptPage)

        self.cutCopiedItems = []
        for column_index in range(3):
            self.treeWidget.setColumnWidth(column_index, cm.ConfigManager.SETTINGS[cm.COLUMN_WIDTHS][column_index])

        h_view = self.treeWidget.header()
        h_view.setSectionResizeMode(QHeaderView.ResizeMode(QHeaderView.Interactive | QHeaderView.ResizeToContents))

        self.logHandler = None
        self.listWidget.hide()

        self.factory = None  # type: ak_tree.WidgetItemFactory
        self.context_menu = None  # type: QMenu
        self.action_clear_log = self._create_action("edit-clear-history", "Clear Log", None, self.on_clear_log)
        self.listWidget.addAction(self.action_clear_log)
        self.action_save_log = self._create_action("edit-clear-history", "Save Log As…", None, self.on_save_log)
        self.listWidget.addAction(self.action_save_log) 
开发者ID:autokey,项目名称:autokey,代码行数:26,代码来源:centralwidget.py

示例5: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, parent=None):
        super(BacktraceWidget, self).__init__(parent=parent)
        self._app_window = parent

        self._app_window.dwarf.onBackTrace.connect(self.set_backtrace)

        self._model = QStandardItemModel(0, 2)
        self._model.setHeaderData(0, Qt.Horizontal, 'Address')
        self._model.setHeaderData(1, Qt.Horizontal, 'Symbol')
        self.setModel(self._model)

        self.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
        self.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
        self.doubleClicked.connect(self._item_double_clicked)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._on_context_menu)
        self._mode = 'native' 
开发者ID:iGio90,项目名称:Dwarf,代码行数:19,代码来源:backtrace.py

示例6: setupGrainTable

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def setupGrainTable(self):
        self.ui.tableWidgetGrainList.clearContents()

        header = self.ui.tableWidgetGrainList.horizontalHeader()
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QHeaderView.Stretch)

        self.updateGrainTable()

        self.ui.pushButtonMoveGrainUp.pressed.connect(lambda: self.moveGrain(-1))
        self.ui.pushButtonMoveGrainDown.pressed.connect(lambda: self.moveGrain(1))
        self.ui.pushButtonDeleteGrain.pressed.connect(self.deleteGrain)
        self.ui.pushButtonCopyGrain.pressed.connect(self.copyGrain)

        self.ui.tableWidgetGrainList.itemSelectionChanged.connect(self.checkGrainSelection)
        self.checkGrainSelection()
        
        self.ui.tableWidgetGrainList.doubleClicked.connect(self.doubleClickGrainSelector) 
开发者ID:reilleya,项目名称:openMotor,代码行数:20,代码来源:mainWindow.py

示例7: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, parent=None):
        super().__init__(parent)

        self.header = self.horizontalHeader()
        self.header.setSectionResizeMode(QHeaderView.ResizeToContents) 
开发者ID:canard0328,项目名称:malss,代码行数:7,代码来源:nonscroll_table.py

示例8: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(parent)
        self.mount_point = None

        header = self.archiveTable.horizontalHeader()
        header.setVisible(True)
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(3, QHeaderView.Stretch)
        header.setStretchLastSection(True)

        if sys.platform != "darwin":
            self._set_status("")  # Set platform-specific hints.

        self.archiveTable.setSelectionBehavior(QTableView.SelectRows)
        self.archiveTable.setEditTriggers(QTableView.NoEditTriggers)
        self.archiveTable.setAlternatingRowColors(True)

        # Populate pruning options from database
        for i in self.prune_intervals:
            getattr(self, f"prune_{i}").setValue(getattr(self.profile(), f"prune_{i}"))
            getattr(self, f"prune_{i}").valueChanged.connect(self.save_prune_setting)

        self.mountButton.clicked.connect(self.mount_action)
        self.listButton.clicked.connect(self.list_action)
        self.pruneButton.clicked.connect(self.prune_action)
        self.checkButton.clicked.connect(self.check_action)
        self.extractButton.clicked.connect(self.extract_action)

        self.populate_from_profile() 
开发者ID:Mebus,项目名称:restatic,代码行数:34,代码来源:archive_tab.py

示例9: _header_double_clicked_handler

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def _header_double_clicked_handler(self, idx):
        self.header().setSectionResizeMode(idx, QHeaderView.ResizeToContents)
        # Has to be QTimer, multithreading.Timer blocks Qt thread for some reason
        QTimer.singleShot(10, lambda: self.header().setSectionResizeMode(idx, QHeaderView.Interactive)) 
开发者ID:BetaRavener,项目名称:uPyLoader,代码行数:6,代码来源:transfer_tree_view.py

示例10: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, parent, info, title):
        super().__init__(parent)

        self.setWindowTitle(
            translate('MediaInfo', 'Media Info') + ' - ' + title)
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self.setMinimumSize(550, 300)
        self.resize(550, 500)

        self.vLayout = QVBoxLayout(self)

        self.infoTree = QTreeWidget(self)
        self.infoTree.setColumnCount(2)
        self.infoTree.setHeaderLabels([translate('MediaInfo', 'Info'),
                                       translate('MediaInfo', 'Value')])
        self.infoTree.setAlternatingRowColors(True)
        self.infoTree.setSelectionMode(QAbstractItemView.NoSelection)
        self.infoTree.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.infoTree.header().setStretchLastSection(False)
        self.infoTree.header().setSectionResizeMode(
            QHeaderView.ResizeToContents)
        self.vLayout.addWidget(self.infoTree)

        self.__generate_items(info)
        self.infoTree.expandAll()

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
        self.vLayout.addWidget(self.buttonBox)

        self.buttonBox.rejected.connect(self.close) 
开发者ID:FrancescoCeruti,项目名称:linux-show-player,代码行数:33,代码来源:media_info.py

示例11: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, cue_model, parent=None):
        """
        :type cue_model: lisp.layouts.list_layout.cue_list_model.CueListModel
        """
        super().__init__(parent)
        self._model = cue_model
        self._model.item_added.connect(self.__cue_added, Connection.QtQueued)
        self._model.item_moved.connect(self.__cue_moved, Connection.QtQueued)
        self._model.item_removed.connect(self.__cue_removed, Connection.QtQueued)
        self._model.model_reset.connect(self.__model_reset)
        self.__item_moving = False

        self.setHeaderLabels(
            [translate('ListLayoutHeader', h) for h in CueListView.HEADER_NAMES])
        self.header().setDragEnabled(False)
        self.header().setStretchLastSection(False)
        self.header().setSectionResizeMode(QHeaderView.Fixed)
        self.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
        self.header().setSectionResizeMode(2, QHeaderView.Stretch)

        self.setColumnWidth(0, 40)
        self.setColumnWidth(len(CueListView.HEADER_NAMES) - 1, 18)
        self.setSelectionMode(self.SingleSelection)
        self.setDragDropMode(self.InternalMove)
        self.setAlternatingRowColors(True)
        self.setVerticalScrollMode(self.ScrollPerItem)

        self.setIndentation(0)

        self.currentItemChanged.connect(self.__current_changed)

        self.__guard = False
        self.verticalScrollBar().rangeChanged.connect(self.__update_range) 
开发者ID:FrancescoCeruti,项目名称:linux-show-player,代码行数:35,代码来源:cue_list_view.py

示例12: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, fs_data, archive):
        super().__init__()
        self.setupUi(self)

        files_with_attributes = []
        nested_file_list = nested_dict()
        self.selected = set()

        def parse_line(line):
            size, modified, full_path = line.split("\t")
            size = int(size)
            dir, name = os.path.split(full_path)

            # add to nested dict of folders to find nested dirs.
            d = get_dict_from_list(nested_file_list, dir.split("/"))
            if name not in d:
                d[name] = {}

            return size, modified, name, dir

        for line in fs_data.split("\n"):
            try:
                files_with_attributes.append(parse_line(line))
            except ValueError:
                pass

        model = ExtractTree(files_with_attributes, nested_file_list, self.selected)

        view = self.treeView
        view.setAlternatingRowColors(True)
        view.setUniformRowHeights(True)  # Allows for scrolling optimizations.
        view.setModel(model)
        header = view.header()
        header.setStretchLastSection(False)
        header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(0, QHeaderView.Stretch)

        self.archiveNameLabel.setText(f"{archive.name}, {archive.time}")
        self.cancelButton.clicked.connect(self.close)
        self.extractButton.clicked.connect(self.accept) 
开发者ID:borgbase,项目名称:vorta,代码行数:43,代码来源:extract_dialog.py

示例13: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, archiveTable):
        super().__init__()
        self.setupUi(self)

        header = self.archiveTable.horizontalHeader()
        header.setVisible(True)
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(2, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(3, QHeaderView.Interactive)
        header.setSectionResizeMode(4, QHeaderView.Stretch)
        header.setStretchLastSection(True)

        self.archiveTable.setSelectionBehavior(QTableView.SelectRows)
        self.archiveTable.setSelectionMode(QTableView.MultiSelection)
        self.archiveTable.setEditTriggers(QTableView.NoEditTriggers)
        self.archiveTable.setWordWrap(False)
        self.archiveTable.setTextElideMode(QtCore.Qt.ElideLeft)
        self.archiveTable.setAlternatingRowColors(True)
        self.archiveTable.itemSelectionChanged.connect(self.itemSelectionChanged_action)

        # Copy archiveTable of MainWindow
        self.archiveTable.setRowCount(archiveTable.rowCount())
        for row in range(archiveTable.rowCount()):
            for column in range(archiveTable.columnCount()):
                try:
                    text = archiveTable.item(row, column).text()
                    self.archiveTable.setItem(row, column, QTableWidgetItem(text))
                except AttributeError:
                    self.archiveTable.setItem(row, column, QTableWidgetItem(""))

        self.diffButton.setEnabled(False)

        self.cancelButton.clicked.connect(self.close)
        self.diffButton.clicked.connect(self.diff_action)
        self.selected_archives = None 
开发者ID:borgbase,项目名称:vorta,代码行数:38,代码来源:diff_dialog.py

示例14: __init__

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def __init__(self, client, *args, **kwargs):
        self.client = client
        self.macros = []
        QWidget.__init__(self, *args, **kwargs)
        
        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        
        buttonLayout = QHBoxLayout()
        new_button = QPushButton("New")
        add_button = QPushButton("Add...")
        remove_button = QPushButton("Remove")
        new_button.clicked.connect(self.new_macro)
        add_button.clicked.connect(self.browse_macro)
        remove_button.clicked.connect(self.remove_selected)
        
        # Set up table
        self.macroListModel = IntMacroListModel(self, self.client)
        self.macroListView = QTableView()
        self.macroListView.setModel(self.macroListModel)

        self.macroListView.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        self.macroListView.verticalHeader().hide()
        self.macroListView.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        self.macroListView.horizontalHeader().hide()
        self.macroListView.horizontalHeader().setStretchLastSection(True)

        self.macroListView.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.macroListView.setSelectionMode(QAbstractItemView.SingleSelection)
        
        buttonLayout.addWidget(new_button)
        buttonLayout.addWidget(add_button)
        buttonLayout.addWidget(remove_button)
        buttonLayout.addStretch()
        self.layout().addWidget(self.macroListView)
        self.layout().addLayout(buttonLayout) 
开发者ID:roglew,项目名称:guppy-proxy,代码行数:38,代码来源:macros.py

示例15: format_table

# 需要导入模块: from PyQt5.QtWidgets import QHeaderView [as 别名]
# 或者: from PyQt5.QtWidgets.QHeaderView import ResizeToContents [as 别名]
def format_table(self, table):
        table.verticalHeader().hide()
        table.horizontalHeader().hide()
        table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        table.horizontalHeader().setStretchLastSection(True) 
开发者ID:roglew,项目名称:guppy-proxy,代码行数:8,代码来源:reqview.py


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