當前位置: 首頁>>代碼示例>>Python>>正文


Python qApp.setStyleSheet方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.qApp.setStyleSheet方法的典型用法代碼示例。如果您正苦於以下問題:Python qApp.setStyleSheet方法的具體用法?Python qApp.setStyleSheet怎麽用?Python qApp.setStyleSheet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.qApp的用法示例。


在下文中一共展示了qApp.setStyleSheet方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: apply_style

# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import setStyleSheet [as 別名]
def apply_style(name):
    """Load a style given its name."""
    style = LiSPStyles.get(name.title())

    if isinstance(style, Style):
        if style.has_py:
            module = __package__ + '.' + os.path.basename(style.path) + '.style'
            __load_py_style(module)

        if style.has_qss:
            __load_qss_style(os.path.join(style.path, 'style.qss'))
    else:
        qApp.setStyleSheet('')
        qApp.setStyle(QStyleFactory.create(name))


# Search for styles 
開發者ID:FrancescoCeruti,項目名稱:linux-show-player,代碼行數:19,代碼來源:styles.py

示例2: setTheme

# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import setStyleSheet [as 別名]
def setTheme(theme):
    """
    根據theme.json設置主題的qss (隻改樣式不加Titlebar)
    :param theme:
    :return:
    """
    THEME_FILE = RESOURCE_DIR + '/theme.json'
    if os.path.isfile(THEME_FILE):
        path = THEME_FILE
    else:
        path = (os.path.split(__file__)[0] + '\\' + THEME_FILE).replace('\\', '/')
    tDict = json.load(open(path))
    # theme.json的theme的優先級比setTheme中的theme的優先級高
    configTheme = tDict.get('theme')
    if configTheme is None or configTheme == '' or tDict.get(configTheme) is None:
        colorDict = tDict.get(theme)
    else:
        colorDict = tDict.get(configTheme)
    if colorDict is None:
        qss = simple_qss.getDefaultQss()
    else:
        qss = simple_qss.getQss(colorDict['fontLight'], colorDict['fontDark'], colorDict['normal'], colorDict['light'],
                                colorDict['deep'], colorDict['disLight'], colorDict['disDark'], theme)
    qApp.setStyleSheet(qss) 
開發者ID:shuoGG1239,項目名稱:QCandyUi,代碼行數:26,代碼來源:CandyWindow.py

示例3: __load_qss_style

# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import setStyleSheet [as 別名]
def __load_qss_style(path):
    """Read and load the stylesheet file."""
    with open(path, mode='r', encoding='utf-8') as f:
        style = f.read()

    qApp.setStyleSheet(style) 
開發者ID:FrancescoCeruti,項目名稱:linux-show-player,代碼行數:8,代碼來源:styles.py

示例4: loadQSS

# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import setStyleSheet [as 別名]
def loadQSS(theme) -> None:
        filename = ':/styles/{}.qss'.format(theme)
        if QFileInfo(filename).exists():
            qssfile = QFile(filename)
            qssfile.open(QFile.ReadOnly | QFile.Text)
            content = QTextStream(qssfile).readAll()
            qApp.setStyleSheet(content) 
開發者ID:ozmartian,項目名稱:vidcutter,代碼行數:9,代碼來源:videostyle.py

示例5: initMenu

# 需要導入模塊: from PyQt5.QtWidgets import qApp [as 別名]
# 或者: from PyQt5.QtWidgets.qApp import setStyleSheet [as 別名]
def initMenu(self):
        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')

        # File menu

        ## add record manually
        addRec = QMenu("Add Record", self)

        act = QAction('Add Car', self)
        act.setStatusTip('Add Car Manually')
        act.triggered.connect(self.addCar)
        addRec.addAction(act)

        act = QAction('Add Rule', self)
        act.setStatusTip('Add Rule Manually')
        act.triggered.connect(self.addRule)
        addRec.addAction(act)

        act = QAction('Add Violation', self)
        act.setStatusTip('Add Violation Manually')
        act.triggered.connect(self.addViolation)
        addRec.addAction(act)

        act = QAction('Add Camera', self)
        act.setStatusTip('Add Camera Manually')
        act.triggered.connect(self.addCamera)
        addRec.addAction(act)

        fileMenu.addMenu(addRec)

        # check archive record ( Create window and add button to restore them)
        act = QAction('&Archives', self)
        act.setStatusTip('Show Archived Records')
        act.triggered.connect(self.showArch)
        fileMenu.addAction(act)

        settingsMenu = menubar.addMenu('&Settings')
        themeMenu = QMenu("Themes", self)
        settingsMenu.addMenu(themeMenu)

        act = QAction('Dark', self)
        act.setStatusTip('Dark Theme')
        act.triggered.connect(lambda: qApp.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()))
        themeMenu.addAction(act)

        act = QAction('White', self)
        act.setStatusTip('White Theme')
        act.triggered.connect(lambda: qApp.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()))
        themeMenu.addAction(act)

        ## Add Exit
        fileMenu.addSeparator()
        act = QAction('&Exit', self)
        act.setShortcut('Ctrl+Q')
        act.setStatusTip('Exit application')
        act.triggered.connect(qApp.quit)
        fileMenu.addAction(act) 
開發者ID:rahatzamancse,項目名稱:Traffic-Rules-Violation-Detection,代碼行數:60,代碼來源:MainWindow.py


注:本文中的PyQt5.QtWidgets.qApp.setStyleSheet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。