Debian Codegraph @

libs/CCAppCommon/QDarkStyleSheet/scripts/run_ui_css_edition.py

raw
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 """
4 Process qrc, ui, image, and screenshot files, then run example in while loop.
5 """
6
7 # Standard library imports
8 import argparse
9 from subprocess import call
10 import os
11 import sys
12 import tempfile
13
14 # Constants
15 SCRIPTS_PATH = os.path.abspath(os.path.dirname(__file__))
16
17
18 def main():
19 """Process qrc and ui files, then run example in while loop."""
20 parser = argparse.ArgumentParser(description=__doc__,
21 formatter_class=argparse.RawDescriptionHelpFormatter)
22 parser.add_argument('--palette',
23 default='dark',
24 choices=['dark', 'light'],
25 type=str,
26 help="Palette to display",)
27
28 # Parsing arguments from command line
29 args = parser.parse_args()
30 palette = args.palette
31
32 styled = None
33 no_styled = None
34 themes = {'Styled': styled, 'No styled': no_styled}
35 shell = True if os.name == 'nt' else False
36 while True:
37 for theme_name, theme_process in themes.items():
38 try:
39 theme_process.kill()
40 except AttributeError:
41 print(theme_name + ' not running!')
42 except Exception:
43 print(theme_name + ' still running!')
44 else:
45 print(theme_name + ' was killed!')
46
47 print(sys.argv)
48
49 # Process qrc files
50 process_qrc = os.path.join(SCRIPTS_PATH, '../qdarkstyle/utils/__main__.py')
51 call(['python', process_qrc], shell=shell)
52
53 # Show window
54 example = os.path.join(SCRIPTS_PATH, '../qdarkstyle/example/__main__.py')
55
56 # Open styled window
57 styled = call(['python', example, '--palette', palette] + sys.argv[1:], shell=shell)
58
59 # Open unstyled window
60 no_styled = call(['python', example, '--palette', 'none'] + sys.argv[1:], shell=shell)
61
62 if styled or no_styled:
63 print('Unf! It not worked! Please, check the error(s).')
64 break
65
66
67 if __name__ == "__main__":
68 sys.exit(main())