From dfef926599de5ebb7e63ad09a256123f622d045c Mon Sep 17 00:00:00 2001 From: Ircama Date: Tue, 13 Aug 2024 22:47:44 +0200 Subject: [PATCH] Add github version --- .github/workflows/build.yml | 3 ++- epson_print_conf.spec | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83c14fa..86ae6f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,8 +27,9 @@ jobs: pip install -r requirements.txt - name: Run PyInstaller to create epson_print_conf.exe - run: | + run: > python -m PyInstaller epson_print_conf.spec -- --default + --version ${{ github.ref_name }} - name: Zip the epson_print_conf.exe asset to epson_print_conf.zip run: | diff --git a/epson_print_conf.spec b/epson_print_conf.spec index 390a478..d405e78 100644 --- a/epson_print_conf.spec +++ b/epson_print_conf.spec @@ -7,12 +7,15 @@ from PIL import Image, ImageDraw, ImageFont def create_image(png_file, text): - img = Image.new('RGB', (800, 150), color='black') - fnt = ImageFont.truetype('arialbd.ttf', 30) + x_size = 800 + y_size = 150 + font_size = 30 + img = Image.new('RGB', (x_size, y_size), color='black') + fnt = ImageFont.truetype('arialbd.ttf', font_size) d = ImageDraw.Draw(img) shadow_offset = 2 bbox = d.textbbox((0, 0), text, font=fnt) - x, y = (800-bbox[2])/2, (150-bbox[3])/2 + x, y = (x_size-bbox[2])/2, (y_size-bbox[3])/2 d.text((x+shadow_offset, y+shadow_offset), text, font=fnt, fill='gray') d.text((x, y), text, font=fnt, fill='#baf8f8') img.save(png_file, 'PNG') @@ -20,6 +23,7 @@ def create_image(png_file, text): parser = argparse.ArgumentParser() parser.add_argument("--default", action="store_true") +parser.add_argument("--version", action="store", default=None) options = parser.parse_args() PROGRAM = [ 'gui.py' ] @@ -28,6 +32,10 @@ BASENAME = 'epson_print_conf' DATAS = [(BASENAME + '.pickle', '.')] SPLASH_IMAGE = BASENAME + '.png' +version = ( + "ui.VERSION = '" + options.version.replace('v', '') + "'" +) if options.version else "" + create_image( SPLASH_IMAGE, 'Epson Printer Configuration tool loading...' ) @@ -38,15 +46,16 @@ if not options.default and not os.path.isfile(DATAS[0][0]): gui_wrapper = """import pyi_splash import pickle -from ui import EpsonPrinterUI +import ui from os import path +""" + version + """ path_to_pickle = path.abspath( path.join(path.dirname(__file__), '""" + DATAS[0][0] + """') ) with open(path_to_pickle, 'rb') as fp: conf_dict = pickle.load(fp) -app = EpsonPrinterUI(conf_dict=conf_dict, replace_conf=False) +app = ui.EpsonPrinterUI(conf_dict=conf_dict, replace_conf=False) pyi_splash.close() app.mainloop() """ @@ -55,10 +64,11 @@ if options.default: DATAS = [] gui_wrapper = """import pyi_splash import pickle -from ui import main +import ui from os import path -app = main() +""" + version + """ +app = ui.main() pyi_splash.close() app.mainloop() """