Files
QDarkStyleSheet/scripts/run_ui_css_edition.py
T

69 lines
2.0 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2019-05-05 13:35:50 -05:00
"""
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
2019-05-06 06:29:07 -05:00
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
2021-03-29 00:37:48 -03:00
styled = None
no_styled = None
themes = {'Styled': styled, 'No styled': no_styled}
2021-07-13 16:11:08 -05:00
shell = True if os.name == 'nt' else False
while True:
2019-05-05 13:35:50 -05:00
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)
2019-05-05 13:35:50 -05:00
# Process qrc files
2021-03-28 23:50:52 -03:00
process_qrc = os.path.join(SCRIPTS_PATH, '../qdarkstyle/utils/__main__.py')
2021-07-13 16:11:08 -05:00
call(['python', process_qrc], shell=shell)
2019-05-05 13:35:50 -05:00
# Show window
2021-03-28 23:50:52 -03:00
example = os.path.join(SCRIPTS_PATH, '../qdarkstyle/example/__main__.py')
2019-05-05 13:35:50 -05:00
2021-03-29 00:37:48 -03:00
# Open styled window
2021-07-13 16:11:08 -05:00
styled = call(['python', example, '--palette', palette] + sys.argv[1:], shell=shell)
2019-05-05 13:35:50 -05:00
2021-03-29 00:37:48 -03:00
# Open unstyled window
2021-07-13 16:11:08 -05:00
no_styled = call(['python', example, '--palette', 'none'] + sys.argv[1:], shell=shell)
2021-03-29 00:37:48 -03:00
if styled or no_styled:
print('Unf! It not worked! Please, check the error(s).')
break
if __name__ == "__main__":
sys.exit(main())