本文整理匯總了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)