2018-02-21 17:28:30 -03:00
|
|
|
#!/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.
|
|
|
|
|
"""
|
2018-02-21 17:28:30 -03:00
|
|
|
|
2019-05-03 15:18:09 -05:00
|
|
|
# Standard library imports
|
2021-03-22 16:27:19 -05:00
|
|
|
import argparse
|
2018-02-21 17:28:30 -03:00
|
|
|
from subprocess import call
|
2019-05-03 15:18:09 -05:00
|
|
|
import os
|
|
|
|
|
import sys
|
2021-03-22 16:27:19 -05:00
|
|
|
import tempfile
|
2019-05-03 15:18:09 -05:00
|
|
|
|
|
|
|
|
# Constants
|
2019-05-06 06:29:07 -05:00
|
|
|
SCRIPTS_PATH = os.path.abspath(os.path.dirname(__file__))
|
2021-03-22 16:27:19 -05:00
|
|
|
|
2021-03-29 02:14:44 -03:00
|
|
|
|
2018-02-21 17:28:30 -03:00
|
|
|
def main():
|
|
|
|
|
"""Process qrc and ui files, then run example in while loop."""
|
2021-03-22 16:27:19 -05:00
|
|
|
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
|
2018-02-21 17:28:30 -03:00
|
|
|
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!')
|
2018-02-21 17:28:30 -03:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2021-03-22 16:27:19 -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)
|
2018-02-21 17:28:30 -03:00
|
|
|
|
2021-03-29 00:37:48 -03:00
|
|
|
if styled or no_styled:
|
2018-02-21 17:28:30 -03:00
|
|
|
print('Unf! It not worked! Please, check the error(s).')
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
sys.exit(main())
|