本文整理汇总了Python中qdarkstyle.load_stylesheet_pyqt5方法的典型用法代码示例。如果您正苦于以下问题:Python qdarkstyle.load_stylesheet_pyqt5方法的具体用法?Python qdarkstyle.load_stylesheet_pyqt5怎么用?Python qdarkstyle.load_stylesheet_pyqt5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qdarkstyle
的用法示例。
在下文中一共展示了qdarkstyle.load_stylesheet_pyqt5方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def __init__(self, systemtray_icon=None, parent=None):
"""Init window."""
super(Window, self).__init__(parent)
self.systemtray_icon = systemtray_icon
self.statusBar()
self.widget = MainWidget(self)
self.setCentralWidget(self.widget)
self.resize(500, 200)
self.setWindowTitle(APP_NAME)
self.setWindowIcon(QIcon(ICON_PATH))
self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
helpAct = QAction('&Help', self)
helpAct.setShortcut('Ctrl+H')
helpAct.setStatusTip('Help')
helpAct.triggered.connect(self.helper)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&About')
fileMenu.addAction(helpAct)
示例2: light_or_dark
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def light_or_dark(self, is_dark):
""" set the UI to a light or dark scheme.
Qt doesn't seem to support controlling the MdiArea's background from a
style sheet. Set the widget directly and save the original color
to reset defaults.
"""
if not hasattr(self, 'mdi_background'):
self.mdi_background = self.mdi.background()
if is_dark:
self.qtapp.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
rgb = DarkPalette.color_palette()
self.mdi.setBackground(QColor(rgb['COLOR_BACKGROUND_NORMAL']))
else:
self.qtapp.setStyleSheet('')
self.mdi.setBackground(self.mdi_background)
return is_dark
示例3: __init__
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def __init__(self, style=""):
if not GStyle.check_style(style):
self.text_color = "black"
self.placehoder_color = "#898b8d"
self.stylesheet = GStyle._base_style +\
"""
._Spliter{
border: 1px inset gray;
}
"""
elif style == "qdarkstyle":
self.text_color = '#eff0f1'
self.placehoder_color = "#898b8d"
self.stylesheet = qdarkstyle.load_stylesheet_pyqt5() +\
GStyle._base_style +\
"""
.GListView{
padding: 5px;
}
._Spliter{
border: 5px solid gray;
}
"""
示例4: _qt_wrapper_import
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def _qt_wrapper_import(qt_api):
"""
Check if Qt API defined can be imported.
:param qt_api: Qt API string to test import
:return load function fot given qt_api, otherwise empty string
"""
qt_wrapper = ''
loader = ""
try:
if qt_api == 'PyQt' or qt_api == 'pyqt':
import PyQt4
qt_wrapper = 'PyQt4'
loader = load_stylesheet_pyqt()
elif qt_api == 'PyQt5' or qt_api == 'pyqt5':
import PyQt5
qt_wrapper = 'PyQt5'
loader = load_stylesheet_pyqt5()
elif qt_api == 'PySide' or qt_api == 'pyside':
import PySide
qt_wrapper = 'PySide'
loader = load_stylesheet_pyside()
elif qt_api == 'PySide2' or qt_api == 'pyside2':
import PySide2
qt_wrapper = 'PySide2'
loader = load_stylesheet_pyside2()
except ImportError as err:
_logger().error("Impossible import Qt wrapper.\n %s", str(err))
else:
_logger().info("Using Qt wrapper = %s ", qt_wrapper)
finally:
return loader
示例5: load_stylesheet_pyqt5
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def load_stylesheet_pyqt5():
"""
Load the stylesheet for use in a pyqt5 application.
:param pyside: True to load the pyside rc file, False to load the PyQt rc file
:return the stylesheet string
"""
warnings.warn(
"load_stylesheet_pyqt5() will be deprecated in version 3,"
"set QtPy environment variable to specify the Qt binding and "
"use load_stylesheet()",
PendingDeprecationWarning
)
# Smart import of the rc file
import qdarkstyle.pyqt5_style_rc
# Load the stylesheet content from resources
from PyQt5.QtCore import QFile, QTextStream
f = QFile(":qdarkstyle/style.qss")
if not f.exists():
_logger().error("Unable to load stylesheet, file not found in "
"resources")
return ""
else:
f.open(QFile.ReadOnly | QFile.Text)
ts = QTextStream(f)
stylesheet = ts.readAll()
if platform.system().lower() == 'darwin': # see issue #12 on github
mac_fix = '''
QDockWidget::title
{
background-color: #31363b;
text-align: center;
height: 12px;
}
'''
stylesheet += mac_fix
return stylesheet
示例6: createQApp
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def createQApp():
"""创建PyQt应用对象"""
# 创建Qt应用对象
qApp = QtWidgets.QApplication([])
# 设置Qt的皮肤
if globalSetting['darkStyle']:
try:
import qdarkstyle
qApp.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
except :
print("Unexpected error when import darkStyle:", sys.exc_info()[0])
# 设置Windows底部任务栏图标
if 'Windows' in platform.uname():
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')
# 设置Qt字体
qApp.setFont(BASIC_FONT)
# 设置Qt图标
qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))
# 返回创建好的QApp对象
return qApp
示例7: enable_dark_mode
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def enable_dark_mode(self, bool):
if bool:
self.app.setStyleSheet("")
else:
self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
示例8: initMenu
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [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)
示例9: main
# 需要导入模块: import qdarkstyle [as 别名]
# 或者: from qdarkstyle import load_stylesheet_pyqt5 [as 别名]
def main():
config_server = None
try:
path = os.path.abspath(os.path.dirname(__file__))
config_file = os.path.join(path, 'config_server.yaml')
with open(os.path.expanduser(config_file), encoding='utf8') as fd:
config_server = yaml.load(fd)
except IOError:
print("config_server.yaml is missing")
config_client = None
try:
path = os.path.abspath(os.path.dirname(__file__))
config_file = os.path.join(path, 'config_client.yaml')
with open(os.path.expanduser(config_file), encoding='utf8') as fd:
config_client = yaml.load(fd)
except IOError:
print("config_client.yaml is missing")
lang_dict = None
font = None
try:
path = os.path.abspath(os.path.dirname(__file__))
config_file = os.path.join(path, 'language/en/live_text.yaml')
font = QtGui.QFont('Microsoft Sans Serif', 10)
if config_client['language'] == 'cn':
config_file = os.path.join(path, 'language/cn/live_text.yaml')
font = QtGui.QFont(u'微软雅黑', 10)
with open(os.path.expanduser(config_file), encoding='utf8') as fd:
lang_dict = yaml.load(fd)
lang_dict['font'] = font
except IOError:
print("live_text.yaml is missing")
app = QtWidgets.QApplication(sys.argv)
mainWindow = MainWindow(config_server, config_client, lang_dict)
if config_client['theme'] == 'dark':
import qdarkstyle
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
mainWindow.showMaximized()
sys.exit(app.exec_())