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


Python QTreeWidget.setStyleSheet方法代码示例

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


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

示例1: DiscoveryDialog

# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setStyleSheet [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: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setStyleSheet [as 别名]
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.dbm_obj = Dbm()
        self.curFile = ''
        self.textEdit = QTextEdit()
        self.sectionTreeWidget = QTreeWidget()

        self.notesListWidget = QListWidget()
        self.createHorizontalGroupBox()
        self.setCentralWidget(self.horizontalGroupBox)

        self.createActions()
        self.createMenus()
        # self.createToolBars()
        self.createStatusBar()
        self.readSettings()

        [self.hierarchy_dict, self.notebook_dict, self.section_dict, self.page_dict] = [{}, {}, {}, {}]

        self.setCurrentFile('')

        # For binding slots and signals
        self.fetchPageThread = FetchPage()
        self.fetchPageThread.setObjectName('fetchPageThread')
        self.syncAllThread = SyncAllThread()
        self.syncAllThread.setObjectName('syncAllThread')
        self.textEdit.document().contentsChanged.connect(self.documentWasModified)
        self.sectionTreeWidget.setObjectName("sectionTreeWidget")
        self.notesListWidget.setObjectName("notesListWidget")
        QMetaObject.connectSlotsByName(self)
        self.readDB()

    @pyqtSlot()
    def on_sectionTreeWidget_itemSelectionChanged(self):
        for x in self.sectionTreeWidget.selectedItems():
            if x.text(1) in self.section_dict.keys():
                self.populate_notes_list(x.parent().text(1), x.text(1))

    @pyqtSlot()
    def on_notesListWidget_itemSelectionChanged(self):
        for x in self.notesListWidget.selectedItems():
            self.fetchPageThread.fetchSignal.connect(self.on_fetchPageThread_fetchComplete)
            self.titleLabel.setText("Syncing")
            self.statusBar().showMessage("Syncing")
            # self.fetchPageThread.fetchSignal.connect(lambda:self.view.setHtml("<body>hello world</body>"))
            self.fetchPageThread.fetch(self.page_dict[x.data(1)])

    def on_fetchPageThread_fetchComplete(self, string):
        self.view.setHtml(string)
        self.titleLabel.setText(self.view.title())
        self.statusBar().showMessage("Page fetched")

    def on_syncAllThread_syncComplete(self, dbm):
        self.dbm_obj = dbm
        self.statusBar().showMessage("Sync complete")

    def createHorizontalGroupBox(self):
        self.horizontalGroupBox = QGroupBox()
        layout = QHBoxLayout()

        self.sectionTreeWidget.setHeaderHidden(1)
        layout.addWidget(self.sectionTreeWidget, 0)
        self.sectionTreeWidget.setStyleSheet("background-color: rgb(215,227,229)")
        self.notesListWidget.setWindowTitle('Notes')
        layout.addWidget(self.notesListWidget, 0)
        self.notesListWidget.setStyleSheet("QListWidget {background-color: rgb(196,226,233)}")

        subVBox = QGroupBox()
        vLayout = QVBoxLayout()

        self.titleLabel = QLabel()
        vLayout.addWidget(self.titleLabel, 0)

        self.view = QWebView()
        vLayout.addWidget(self.view, 1)

        subVBox.setLayout(vLayout)

        layout.addWidget(subVBox, 1)

        self.horizontalGroupBox.setLayout(layout)

    def closeEvent(self, event):
        if self.maybeSave():
            self.writeSettings()
            event.accept()
        else:
            event.ignore()

    def newFile(self):
        self.readDB()
        # if self.maybeSave():
        #     self.textEdit.clear()
        #     self.setCurrentFile('')

    def open(self):
        if self.maybeSave():
            fileName, _ = QFileDialog.getOpenFileName(self)
            if fileName:
#.........这里部分代码省略.........
开发者ID:lighht,项目名称:pyonenote-old,代码行数:103,代码来源:mainUI.py


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