File: run_ui_css_edition.py

package info (click to toggle)
qdarkstyle 3.2.3%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,012 kB
  • sloc: python: 23,901; sh: 31; makefile: 5
file content (68 lines) | stat: -rwxr-xr-x 2,083 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Process qrc, ui, image, and screenshot files, then run example in while loop.
"""

# Standard library imports
import argparse
from subprocess import call
import os
import sys
import tempfile

# Constants
SCRIPTS_PATH = os.path.abspath(os.path.dirname(__file__))


def main():
    """Process qrc and ui files, then run example in while loop."""
    parser = argparse.ArgumentParser(description=__doc__,
                                     formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('--palette',
                        default='dark',
                        choices=['dark', 'light'],
                        type=str,
                        help="Palette to display",)

    # Parsing arguments from command line
    args = parser.parse_args()
    palette = args.palette

    styled = None
    no_styled = None
    themes = {'Styled': styled, 'No styled': no_styled}
    shell = True if os.name == 'nt' else False
    while True:
        for theme_name, theme_process in themes.items():
            try:
                theme_process.kill()
            except AttributeError:
                print(theme_name + ' not running!')
            except Exception:
                print(theme_name + ' still running!')
            else:
                print(theme_name + ' was killed!')

        print(sys.argv)

        # Process qrc files
        process_qrc = os.path.join(SCRIPTS_PATH, '../qdarkstyle/utils/__main__.py')
        call(['python', process_qrc], shell=shell)

        # Show window
        example = os.path.join(SCRIPTS_PATH, '../qdarkstyle/example/__main__.py')

        # Open styled window
        styled = call(['python', example, '--palette', palette] + sys.argv[1:], shell=shell)

        # Open unstyled window
        no_styled = call(['python', example, '--palette', 'none'] + sys.argv[1:], shell=shell)

        if styled or no_styled:
            print('Unf! It not worked! Please, check the error(s).')
            break


if __name__ == "__main__":
    sys.exit(main())