예제 #1
0
    def update_css(self):
        """Re-read the stylesheet for the window."""
        # compile the scss file
        qtsass.compile_filename(
            "templates/qtsass/window.scss", "sites/style/window.css"
        )

        with open("sites/style/window.css", "r") as f:
            self.setStyleSheet(f.read())
예제 #2
0
def compile():
    import qtsass
    # Compile SCSS into QSS
    qtsass.compile_filename(os.path.join(dirname, "stylesheets/dark.scss"),
                            os.path.join(dirname, "compiled/dark.qss"))
    qtsass.compile_filename(os.path.join(dirname, "stylesheets/light.scss"),
                            os.path.join(dirname, "compiled/light.qss"))
    # Compile resources defined by style.qrc into a python module
    os.system(f"pyrcc5 {dirname}/stylesheets/main.qrc -o {dirname}/compiled/qtstylish_rc.py")
    # This part is for hot reload
    with open(os.path.join(dirname, "compiled/dark.qss")) as f:
        global DARK
        DARK = f.read()
    with open(os.path.join(dirname, "compiled/light.qss")) as f:
        global LIGHT
        LIGHT = f.read()
예제 #3
0
def _create_qss(main_scss_path, qss_filepath, header=HEADER_QSS):
    """Create a styles.qss file from qtsass."""
    data = ''

    qtsass.compile_filename(main_scss_path, qss_filepath,
                            output_style='expanded')

    with open(qss_filepath, 'r') as f:
        data = f.read()

    data = header.format(qtsass.__version__) + data

    with open(qss_filepath, 'w') as f:
        f.write(data)

    return data
예제 #4
0
def _create_qss(main_scss_path, qss_filepath, header=HEADER_QSS):
    """Create a styles.qss file from qtsass."""
    data = ''
    if QTSASS_INSTALLED:
        qtsass.compile_filename(main_scss_path,
                                qss_filepath,
                                output_style='expanded')

        with open(qss_filepath, 'r') as f:
            data = f.read()

        data = header + data

        with open(qss_filepath, 'w') as f:
            f.write(data)

    return data
예제 #5
0
def _create_qss(main_scss_path, qss_filepath, header=HEADER_QSS):
    """Create a styles.qss file from qtsass."""

    data = ''

    _logger.info("Generating QSS file ...")
    _logger.info("File path: %s" % os.path.join(main_scss_path, qss_filepath))

    qtsass.compile_filename(main_scss_path,
                            qss_filepath,
                            output_style='expanded')

    with open(qss_filepath, 'r') as f:
        data = f.read()

    data = header.format(qtsass.__version__) + data

    with open(qss_filepath, 'w') as f:
        f.write(data)

    return data
예제 #6
0
def test_compile_filename_imports(tmpdir):
    """compile_filename with imports."""

    output = tmpdir.join('dark.css')
    qtsass.compile_filename(example('complex', 'dark.scss'), output.strpath)
    assert exists(output.strpath)
예제 #7
0
def test_compile_filename(tmpdir):
    """compile_filename simple."""

    output = tmpdir.join('dummy.css')
    qtsass.compile_filename(example('dummy.scss'), output.strpath)
    assert exists(output.strpath)