mirror of
https://github.com/ColinDuquesnoy/QDarkStyleSheet.git
synced 2026-08-29 16:40:31 +08:00
Make process_ui.py and run_ui_css_edition.py run for both palettes
This commit is contained in:
committed by
juanis2112
parent
4587b03f45
commit
a62daeb8b1
+32
-3
@@ -26,11 +26,17 @@ from subprocess import call
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import string
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# Constants
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
REPO_ROOT = os.path.dirname(HERE)
|
||||
DEFAULT_EXAMPLE_DIR = os.path.join(REPO_ROOT, 'example')
|
||||
DEFAULT_UI_DIR = os.path.join(DEFAULT_EXAMPLE_DIR, 'ui')
|
||||
EXAMPLE_TMP_DIR = os.path.join(tempfile.gettempdir(), 'qdarkstyle_example')
|
||||
|
||||
|
||||
def main(arguments):
|
||||
@@ -38,7 +44,7 @@ def main(arguments):
|
||||
parser = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('--ui_dir',
|
||||
default=os.path.join(REPO_ROOT, 'example', 'ui'),
|
||||
default=DEFAULT_UI_DIR,
|
||||
type=str,
|
||||
help="UI files directory, relative to current directory.",)
|
||||
parser.add_argument('--create',
|
||||
@@ -46,15 +52,38 @@ def main(arguments):
|
||||
choices=['pyqt', 'pyqt5', 'pyside', 'pyside2', 'qtpy', 'pyqtgraph', 'all'],
|
||||
type=str,
|
||||
help="Choose which one would be generated.")
|
||||
parser.add_argument('--palette',
|
||||
default='dark',
|
||||
choices=['dark', 'light'],
|
||||
type=str,
|
||||
help="Palette to display",)
|
||||
|
||||
args = parser.parse_args(arguments)
|
||||
|
||||
print('Changing directory to: ', args.ui_dir)
|
||||
os.chdir(args.ui_dir)
|
||||
if args.ui_dir == DEFAULT_UI_DIR:
|
||||
shutil.rmtree(EXAMPLE_TMP_DIR, ignore_errors=True)
|
||||
shutil.copytree(DEFAULT_EXAMPLE_DIR, EXAMPLE_TMP_DIR)
|
||||
ui_dir = os.path.join(EXAMPLE_TMP_DIR, 'ui')
|
||||
else:
|
||||
ui_dir = args.ui_dir
|
||||
|
||||
print('Changing directory to: ', ui_dir)
|
||||
os.chdir(ui_dir)
|
||||
|
||||
print('Converting .ui to .py ...')
|
||||
|
||||
for ui_file in glob.glob('*.ui'):
|
||||
|
||||
# Replace palette identifier placeholders
|
||||
if args.ui_dir == DEFAULT_UI_DIR:
|
||||
with open(ui_file, 'r+') as f:
|
||||
contents = f.read()
|
||||
template = string.Template(contents)
|
||||
contents = template.substitute(ID=args.palette)
|
||||
f.seek(0)
|
||||
f.write(contents)
|
||||
f.truncate()
|
||||
|
||||
# get name without extension
|
||||
filename = os.path.splitext(ui_file)[0]
|
||||
print(filename, '...')
|
||||
|
||||
@@ -6,17 +6,34 @@ Process qrc, ui, image, and screenshot files, then run example in while loop.
|
||||
|
||||
# Standard library imports
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import argparse
|
||||
from subprocess import call
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# Constants
|
||||
SCRIPTS_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
REPO_PATH = os.path.dirname(SCRIPTS_PATH)
|
||||
|
||||
# This needs to be the same one defined in process_ui.py
|
||||
EXAMPLE_TMP_DIR = os.path.join(tempfile.gettempdir(), 'qdarkstyle_example')
|
||||
|
||||
|
||||
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
|
||||
|
||||
dark = None
|
||||
no_dark = None
|
||||
themes = {'Dark': dark, 'No Dark': no_dark}
|
||||
@@ -33,21 +50,17 @@ def main():
|
||||
|
||||
print(sys.argv)
|
||||
|
||||
# Process images
|
||||
process_images = os.path.join(SCRIPTS_PATH, 'process_images.py')
|
||||
call(['python', process_images])
|
||||
|
||||
# Process qrc files
|
||||
process_qrc = os.path.join(SCRIPTS_PATH, 'process_qrc.py')
|
||||
call(['python', process_qrc])
|
||||
|
||||
# Process ui files
|
||||
process_ui = os.path.join(SCRIPTS_PATH, 'process_ui.py')
|
||||
call(['python', process_ui])
|
||||
call(['python', process_ui, '--palette', palette])
|
||||
|
||||
# Create screenshots
|
||||
example = os.path.join(REPO_PATH, 'example', 'example.py')
|
||||
call(['python', example, '--screenshots'])
|
||||
# Show window
|
||||
example = os.path.join(EXAMPLE_TMP_DIR, 'example.py')
|
||||
call(['python', example, '--screenshots', '--palette', palette])
|
||||
call(['python', example, '--no_dark', '--screenshots'])
|
||||
|
||||
# Open dark example
|
||||
|
||||
Reference in New Issue
Block a user