当前位置: 首页>>代码示例>>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;未经允许,请勿转载。