本文整理汇总了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
示例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)
示例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)
示例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)
示例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)