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


Python QTreeWidget.setIndentation方法代码示例

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


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

示例1: DiscoveryDialog

# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setIndentation [as 别名]
class DiscoveryDialog(QDialog):
    def __init__(self, parent=None):
        super(DiscoveryDialog, self).__init__(parent)
        self.setModal(True)
        self.setMinimumSize(200,200) # To prevent Geometry error
        self.hosts = []
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.serverview = QTreeWidget()
        self.serverview.setHeaderLabels(['Server', 'Ports'])
        self.serverview.setIndentation(0)
        self.serverview.setStyleSheet('padding:0px')
        self.serverview.header().resizeSection(0, 180)
        layout.addWidget(self.serverview)
        btns = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        layout.addWidget(btns)
        btns.accepted.connect(self.on_accept)
        btns.rejected.connect(parent.closeEvent)

        bs.net.server_discovered.connect(self.add_srv)

    def add_srv(self, address, ports):
        for host in self.hosts:
            if address == host.address and ports == host.ports:
                # We already know this server, skip
                return
        host = QTreeWidgetItem(self.serverview)
        host.address = address
        host.ports = ports
        host.hostname = 'This computer' if address == get_ownip() else address
        host.setText(0, host.hostname)

        host.setText(1, '{},{}'.format(*ports))
        self.hosts.append(host)

    def on_accept(self):
        host = self.serverview.currentItem()
        if host:
            bs.net.stop_discovery()
            hostname = host.address
            eport, sport = host.ports
            bs.net.connect(hostname=hostname, event_port=eport, stream_port=sport)
            self.close()
开发者ID:isabelmetz,项目名称:bluesky,代码行数:45,代码来源:mainwindow.py

示例2: CueListDialog

# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setIndentation [as 别名]
class CueListDialog(QDialog):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.setMinimumSize(400, 300)

        self._cues = []

        self.list = QTreeWidget(self)
        self.list.setSelectionMode(self.list.SingleSelection)
        self.list.setSelectionBehavior(self.list.SelectRows)
        self.list.setAlternatingRowColors(True)
        self.list.setIndentation(0)
        self.list.setHeaderLabels(['Index', 'Name'])
        self.list.header().setSectionResizeMode(QHeaderView.Fixed)
        self.list.header().setSectionResizeMode(1, QHeaderView.Stretch)
        self.list.header().setStretchLastSection(False)

        self.setLayout(QVBoxLayout())
        self.layout().addWidget(self.list)

        self.buttons = QDialogButtonBox(self)
        self.buttons.addButton(QDialogButtonBox.Cancel)
        self.buttons.addButton(QDialogButtonBox.Ok)
        self.layout().addWidget(self.buttons)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

    def add_cue(self, cue):
        try:
            item = QTreeWidgetItem()
            item.setTextAlignment(0, Qt.AlignCenter)

            for n, prop in enumerate(['index', 'name']):
                item.setText(n, str(cue.properties().get(prop, 'Undefined')))

            self._cues.append(cue)
            self.list.addTopLevelItem(item)
        except Exception:
            pass

    def add_cues(self, cues):
        for cue in cues:
            self.add_cue(cue)

    def remove_cue(self, index):
        self.list.takeTopLevelItem(index)
        return self._cues.pop(index)

    def reset(self):
        self.list.clear()
        self._cues.clear()

    def selected_cues(self):
        cues = []
        for item in self.list.selectedItems():
            index = self.list.indexOfTopLevelItem(item)
            cues.append(self._cues[index])
        return cues
开发者ID:tornel,项目名称:linux-show-player,代码行数:63,代码来源:cuelistdialog.py

示例3: Ui_Ucics

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

#.........这里部分代码省略.........
        # ------------添加到布局
        toolLayout.addWidget(self.qzoneButton, 0, Qt.AlignLeft)
        toolLayout.addWidget(self.skinButton, 1, Qt.AlignLeft)
        # --------添加到布局
        headInfoLayout.addWidget(self.nameLabel)
        headInfoLayout.addWidget(self.moodEdit)
        headInfoLayout.addWidget(self.toolWidget)
        # ----天气
        self.weatherLabel = QLabel(self.headWidget)
        self.weatherLabel.setMinimumWidth(60)
        self.weatherLabel.setMaximumWidth(60)
        self.weatherLabel.setCursor(QCursor(Qt.PointingHandCursor))
        self.weatherLabel.setObjectName("weatherLabel")
        # ----添加到布局中
        headLayout.addWidget(self.headLabel, 0, Qt.AlignLeft)
        headLayout.addWidget(self.headInfoWidget, 0, Qt.AlignCenter)
        headLayout.addWidget(self.weatherLabel, 0, Qt.AlignRight)

        # 搜索输入框
        self.searchEdit = LineEdit(self.bgWidget)
        self.searchEdit.setFrame(False)
        # self.searchEdit.setClearButtonEnabled(True)
        self.searchEdit.setObjectName("searchEdit")

        # tab
        self.tabWidget = QTabWidget(self.bgWidget)
        self.tabWidget.setUsesScrollButtons(False)    # 取消两个切换按钮
        self.tabWidget.setDocumentMode(True)    # 取消边框
        self.tabWidget.setObjectName("tabWidget")
        # --分组
        self.tabGroup = QWidget(self.tabWidget)
        self.tabGroup.setObjectName("tabGroup")
        # ----分组布局
        groupVerticalLayout = QVBoxLayout(self.tabGroup)
        groupVerticalLayout.setSpacing(0)
        groupVerticalLayout.setContentsMargins(0, 0, 0, 0)
        groupVerticalLayout.setObjectName("groupVerticalLayout")
        # ------分组list控件
        self.groupTreeWidget = QTreeWidget(self.tabGroup)
        self.groupTreeWidget.setFrameShape(QFrame.NoFrame)
        self.groupTreeWidget.setFrameStyle(QFrame.NoFrame)
        self.groupTreeWidget.setLineWidth(0)
        self.groupTreeWidget.setIndentation(0)
        self.groupTreeWidget.setRootIsDecorated(False)
        self.groupTreeWidget.setExpandsOnDoubleClick(False)
        self.groupTreeWidget.header().setVisible(False)
        self.groupTreeWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.groupTreeWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.groupTreeWidget.setObjectName("groupTreeWidget")
        # ----添加到布局
        groupVerticalLayout.addWidget(self.groupTreeWidget)
        # --历史
        self.tabHistory = QWidget(self.tabWidget)
        self.tabHistory.setObjectName("tabHistory")
        # ----历史布局
        historyVerticalLayout = QVBoxLayout(self.tabHistory)
        historyVerticalLayout.setSpacing(0)
        historyVerticalLayout.setContentsMargins(0, 0, 0, 0)
        historyVerticalLayout.setObjectName("historyVerticalLayout")
        # ------历史list控件
        self.historyTreeWidget = QTreeWidget(self.tabHistory)
        self.historyTreeWidget.setFrameShape(QFrame.NoFrame)
        self.historyTreeWidget.setFrameStyle(QFrame.NoFrame)
        self.historyTreeWidget.setLineWidth(0)
        self.historyTreeWidget.setIndentation(0)
        self.historyTreeWidget.setRootIsDecorated(False)
        self.historyTreeWidget.setExpandsOnDoubleClick(False)
        self.historyTreeWidget.header().setVisible(False)
        self.historyTreeWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.historyTreeWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.historyTreeWidget.setObjectName("historyTreeWidget")
        # ----添加到布局
        historyVerticalLayout.addWidget(self.historyTreeWidget)
        # 添加到tab中
        self.tabWidget.addTab(self.tabGroup, "")
        self.tabWidget.addTab(self.tabHistory, "")

        # 整体布局
        verticalLayout = QVBoxLayout(self.bgWidget)
        verticalLayout.setSpacing(0)
        verticalLayout.setContentsMargins(0, 0, 0, 0)
        verticalLayout.setObjectName("verticalLayout")
        verticalLayout.addWidget(self.topWidget)
        verticalLayout.addWidget(self.headWidget)
        verticalLayout.addWidget(self.searchEdit)
        verticalLayout.addWidget(self.tabWidget)

        # bg
        layout = QVBoxLayout(Ucics)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.bgWidget)

        # 初始化一些设置
        _translate = QCoreApplication.translate
        Ucics.setWindowTitle(_translate("Ucics", "UCICS"))
        self.tabWidget.setCurrentIndex(0)
        self.tabWidget.setTabToolTip(self.tabWidget.indexOf(self.tabGroup), _translate("tabGroup", "分组"))
        self.tabWidget.setTabToolTip(self.tabWidget.indexOf(self.tabHistory), _translate("tabHistory", "历史"))
        QMetaObject.connectSlotsByName(Ucics)
开发者ID:892768447,项目名称:ucics,代码行数:104,代码来源:ui_ucics.py

示例4: CueListDialog

# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setIndentation [as 别名]
class CueListDialog(QDialog):
    def __init__(self, cues=None, properties=('index', 'name'), **kwargs):
        super().__init__(**kwargs)

        self.setMinimumSize(600, 400)

        self._properties = list(properties)
        self._cues = {}

        self.list = QTreeWidget(self)
        self.list.setSelectionMode(QTreeWidget.SingleSelection)
        self.list.setSelectionBehavior(QTreeWidget.SelectRows)
        self.list.setAlternatingRowColors(True)
        self.list.setIndentation(0)
        self.list.setHeaderLabels([prop.title() for prop in properties])
        self.list.header().setSectionResizeMode(QHeaderView.Fixed)
        self.list.header().setSectionResizeMode(1, QHeaderView.Stretch)
        self.list.header().setStretchLastSection(False)
        self.list.sortByColumn(0, Qt.AscendingOrder)
        self.list.setSortingEnabled(True)

        if cues is not None:
            self.add_cues(cues)

        self.setLayout(QVBoxLayout())
        self.layout().addWidget(self.list)

        self.buttons = QDialogButtonBox(self)
        self.buttons.addButton(QDialogButtonBox.Cancel)
        self.buttons.addButton(QDialogButtonBox.Ok)
        self.layout().addWidget(self.buttons)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

    def add_cue(self, cue):
        item = QTreeWidgetItem()
        item.setTextAlignment(0, Qt.AlignCenter)

        for n, prop in enumerate(self._properties):
            try:
                item.setData(n, Qt.DisplayRole, getattr(cue, prop, 'Undefined'))
            except Exception as e:
                logging.exception('Cannot display {0} property'.format(prop), e,
                                  dialog=False)

        self._cues[cue] = item
        item.setData(0, Qt.UserRole, cue)
        self.list.addTopLevelItem(item)

    def add_cues(self, cues):
        self.list.setSortingEnabled(False)
        for cue in cues:
            self.add_cue(cue)
        self.list.setSortingEnabled(True)

    def remove_cue(self, cue):
        index = self.list.indexOfTopLevelItem(self._cues.pop(cue))
        self.list.takeTopLevelItem(index)

    def reset(self):
        self.list.clear()
        self._cues.clear()

    def selected_cues(self):
        cues = []
        for item in self.list.selectedItems():
            cues.append(item.data(0, Qt.UserRole))
        return cues
开发者ID:chippey,项目名称:linux-show-player,代码行数:71,代码来源:cuelistdialog.py


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