Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
[*] Add ico conversion script
Browse files Browse the repository at this point in the history
Rework helper scripts.
  • Loading branch information
IceflowRE committed Dec 13, 2020
1 parent 870150f commit d5aed54
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade -e .[dev,gui]
pip install codecov
mp3monitoring --version
- name: Build
shell: bash
run: |
python ./scripts/ui_to_py.py
python ./scripts/tools.py uic
python ./scripts/tools.py ico
python setup.py clean --all
python setup.py bdist_wheel
mp3monitoring --version
- name: Code style check
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ installer/bin/
installer/hybrid/packages/mp3monitoring/data/
installer/hybrid/packages/mp3monitoring/meta/LICENSE.md
installer/hybrid/packages/mp3monitoring.gui/data/
installer/hybrid/packages/mp3monitoring.updater/data/
installer/hybrid/packages/mp3monitoring.updater/data/
Empty file added mp3monitoring/__main__.py
Empty file.
1 change: 1 addition & 0 deletions mp3monitoring/gui/pkg_data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logo.ico
6 changes: 4 additions & 2 deletions mp3monitoring/gui/pkg_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from importlib import resources
from pathlib import Path

with resources.path('mp3monitoring.gui.pkg_data', 'icon.svg') as p:
LOGO_ICON = Path(p)
with resources.path('mp3monitoring.gui.pkg_data', 'logo.svg') as p:
LOGO = Path(p)
with resources.path('mp3monitoring.gui.pkg_data', 'logo.ico') as p:
LOGO_ICO = Path(p)

with resources.path('mp3monitoring.gui.pkg_data.symbols', 'error.svg') as p:
ERROR_SYMBOL = Path(p)
Expand Down
File renamed without changes
37 changes: 37 additions & 0 deletions scripts/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import subprocess
import sys
from argparse import ArgumentParser
from pathlib import Path


def gen_logo_ico():
sizes = ["16", "32", "64", "128", "256", "512", "1024"]
Path("./build").mkdir(exist_ok=True)
for size in sizes:
subprocess.run(["inkscape", "-w", str(size), "-h", str(size), "-o", f"./build/{size}.png", "./mp3monitoring/gui/pkg_data/logo.svg"])
subprocess.run(["magick", "convert", *[f"./build/{size}.png" for size in sizes], "./mp3monitoring/gui/pkg_data//logo.ico"], stdout=sys.stdout,
stderr=sys.stderr)


def ui_to_py():
output_dir = Path("./mp3monitoring/gui/ui")
for ui_file in Path("./gui").glob("*.ui"):
subprocess.run(["pyside2-uic", str(ui_file), "-o", output_dir.joinpath(ui_file.stem + '.py')], stdout=sys.stdout, stderr=sys.stderr)


if __name__ == '__main__':
parser = ArgumentParser(prog="MP3 Monitoring Development Tools")

subparsers = parser.add_subparsers(dest="tool", help='')

parser_uic = subparsers.add_parser('uic', help='invoke pyside2-uic and create python files')
parser_ico = subparsers.add_parser('ico', help='generate an ico from the logo svg')

if sys.version_info[0] < 3 or sys.version_info[1] < 8:
sys.exit('Only Python 3.8 or greater is supported. You are using:' + sys.version)

args = parser.parse_args(sys.argv[1:])
if args.tool == "uic":
ui_to_py()
elif args.tool == "ico":
gen_logo_ico()
8 changes: 0 additions & 8 deletions scripts/ui_to_py.py

This file was deleted.

0 comments on commit d5aed54

Please sign in to comment.