Python qdarkstyle.load_stylesheet_pyqt5() Examples

The following are 13 code examples of qdarkstyle.load_stylesheet_pyqt5(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module qdarkstyle , or try the search function .
Example #1
Source File: work_log.py    From Awesome-Scripts with MIT License 6 votes vote down vote up
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) 
Example #2
Source File: rayopticsapp.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #3
Source File: quick.py    From quick with GNU General Public License v3.0 6 votes vote down vote up
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;
                        }
                    """ 
Example #4
Source File: work_log.py    From Awesome-Python-Scripts with MIT License 6 votes vote down vote up
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) 
Example #5
Source File: __init__.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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 
Example #6
Source File: __init__.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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 
Example #7
Source File: uiQt.py    From vnpy_crypto with MIT License 5 votes vote down vote up
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 
Example #8
Source File: reaper.py    From reaper with GNU General Public License v3.0 5 votes vote down vote up
def enable_dark_mode(self, bool):
        if bool:
            self.app.setStyleSheet("")
        else:
            self.app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 
Example #9
Source File: work_log.py    From Awesome-Scripts with MIT License 4 votes vote down vote up
def __init__(self, parent=None, repository=None, systemtray_icon=None):
        """Init window."""
        super(WorkLogPreviewer, self).__init__(parent)

        saveAct = QAction(QIcon(SAVE_ICON_PATH), '&Save', self)
        saveAct.setShortcut('Ctrl+S')
        saveAct.setStatusTip('Save work log')
        saveAct.triggered.connect(self.save)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(saveAct)

        self.repository = repository
        self.systemtray_icon = systemtray_icon

        self.statusBar()

        widget = QWidget()
        layout = QVBoxLayout()
        self.te = QPlainTextEdit()
        layout.addWidget(self.te)

        self.lbl = QLabel()
        self.lbl.hide()
        self.movie = QMovie(LOADER_PATH)
        self.lbl.setMovie(self.movie)
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(self.lbl)
        hlayout.addStretch()
        layout.addLayout(hlayout)

        self.generate_log()

        widget.setLayout(layout)
        widget.setFixedSize(500, 500)
        self.setCentralWidget(widget)

        self.setWindowTitle(f'Work log for {repository.full_name}')
        self.setWindowIcon(QIcon(ICON_PATH))
        self.setLocale(QtCore.QLocale())
        self.adjustSize()

        self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 
Example #10
Source File: live_engine.py    From EliteQuant_Python with Apache License 2.0 4 votes vote down vote up
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_()) 
Example #11
Source File: work_log.py    From Awesome-Python-Scripts with MIT License 4 votes vote down vote up
def __init__(self, parent=None, repository=None, systemtray_icon=None):
        """Init window."""
        super(WorkLogPreviewer, self).__init__(parent)

        saveAct = QAction(QIcon(SAVE_ICON_PATH), '&Save', self)
        saveAct.setShortcut('Ctrl+S')
        saveAct.setStatusTip('Save work log')
        saveAct.triggered.connect(self.save)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(saveAct)

        self.repository = repository
        self.systemtray_icon = systemtray_icon

        self.statusBar()

        widget = QWidget()
        layout = QVBoxLayout()
        self.te = QPlainTextEdit()
        layout.addWidget(self.te)

        self.lbl = QLabel()
        self.lbl.hide()
        self.movie = QMovie(LOADER_PATH)
        self.lbl.setMovie(self.movie)
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(self.lbl)
        hlayout.addStretch()
        layout.addLayout(hlayout)

        self.generate_log()

        widget.setLayout(layout)
        widget.setFixedSize(500, 500)
        self.setCentralWidget(widget)

        self.setWindowTitle(f'Work log for {repository.full_name}')
        self.setWindowIcon(QIcon(ICON_PATH))
        self.setLocale(QtCore.QLocale())
        self.adjustSize()

        self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 
Example #12
Source File: MainWindow.py    From Traffic-Rules-Violation-Detection-System with GNU General Public License v3.0 4 votes vote down vote up
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) 
Example #13
Source File: MainWindow.py    From Traffic-Rules-Violation-Detection with GNU General Public License v3.0 3 votes vote down vote up
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)