How to use the qdarkstyle.RC_PATH function in QDarkStyle

To help you get started, we’ve selected a few QDarkStyle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ColinDuquesnoy / QDarkStyleSheet / qdarkstyle / utils / scss.py View on Github external
as a lowercased folder (even if the identifier had uppercase letters).

    This fuction returns the custom stylesheet pointing to resources stored at
    .../path/name/.
    """
    stylesheet = ''

    # Check if name is valid
    if is_identifier(name):
        name = name if name[0].isupper() else name.capitalize()
    else:
        raise Exception('The custom palette name must be a valid Python '
                        'identifier!')

    # Copy resources folder
    rc_loc = os.path.basename(RC_PATH)
    qss_loc = os.path.basename(QSS_PATH)
    theme_root_path = os.path.join(path, name.lower())
    theme_rc_path = os.path.join(theme_root_path, rc_loc)

    if os.path.isdir(theme_root_path):
        shutil.rmtree(theme_root_path)

    shutil.copytree(RC_PATH, theme_rc_path)

    # Copy QSS folder and contents
    theme_qss_path = os.path.join(theme_root_path, qss_loc)

    if os.path.isdir(theme_qss_path):
        os.removedirs(theme_qss_path)

    shutil.copytree(QSS_PATH, theme_qss_path)
github ColinDuquesnoy / QDarkStyleSheet / qdarkstyle / utils / scss.py View on Github external
if is_identifier(name):
        name = name if name[0].isupper() else name.capitalize()
    else:
        raise Exception('The custom palette name must be a valid Python '
                        'identifier!')

    # Copy resources folder
    rc_loc = os.path.basename(RC_PATH)
    qss_loc = os.path.basename(QSS_PATH)
    theme_root_path = os.path.join(path, name.lower())
    theme_rc_path = os.path.join(theme_root_path, rc_loc)

    if os.path.isdir(theme_root_path):
        shutil.rmtree(theme_root_path)

    shutil.copytree(RC_PATH, theme_rc_path)

    # Copy QSS folder and contents
    theme_qss_path = os.path.join(theme_root_path, qss_loc)

    if os.path.isdir(theme_qss_path):
        os.removedirs(theme_qss_path)

    shutil.copytree(QSS_PATH, theme_qss_path)

    # Create custom palette
    custom_palette = type(name, (DarkPalette, ), {})
    custom_palette.COLOR_BACKGROUND_LIGHT = color_background_light
    custom_palette.COLOR_BACKGROUND_NORMAL = color_background_normal
    custom_palette.COLOR_BACKGROUND_DARK = color_background_dark
    custom_palette.COLOR_FOREGROUND_LIGHT = color_foreground_light
    custom_palette.COLOR_FOREGROUND_NORMAL = color_foreground_normal
github ColinDuquesnoy / QDarkStyleSheet / qdarkstyle / utils / images.py View on Github external
Search all RC folder for PNG images and create a QRC file.

    Args:
        resource_prefix (str, optional): Prefix used in resources.
            Defaults to 'qss_icons'.
        style_prefix (str, optional): Prefix used to this style.
            Defaults to 'qdarkstyle'.
    """

    files = []

    _logger.info("Generating QRC file ...")
    _logger.info("Resource prefix: %s" % resource_prefix)
    _logger.info("Style prefix: %s" % style_prefix)

    _logger.info("Searching in: %s" % RC_PATH)

    # Search by png images
    for fname in sorted(os.listdir(RC_PATH)):
        files.append(TEMPLATE_QRC_FILE.format(fname=fname))

    # Join parts
    qrc_content = (TEMPLATE_QRC_HEADER.format(resource_prefix=resource_prefix)
                   + '\n'.join(files)
                   + TEMPLATE_QRC_FOOTER.format(style_prefix=style_prefix))

    _logger.info("Writing in: %s" % QRC_FILEPATH)

    # Write qrc file
    with open(QRC_FILEPATH, 'w') as fh:
        fh.write(qrc_content)