Skip to content

Commit

Permalink
Add github version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ircama committed Aug 13, 2024
1 parent 58dbd5c commit dfef926
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
24 changes: 17 additions & 7 deletions epson_print_conf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ 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')


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' ]
Expand All @@ -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...'
)
Expand All @@ -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()
"""
Expand All @@ -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()
"""
Expand Down

0 comments on commit dfef926

Please sign in to comment.