Skip to content

Commit

Permalink
Added README, updated build script and added example gif
Browse files Browse the repository at this point in the history
  • Loading branch information
80sVectorz committed Oct 29, 2024
1 parent 3ec5ee7 commit 72ba35b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
outputs/
documentation/example_gif_frames

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# QR Code Stencilator

![Example](https://github.com/80sVectorz/qr_code_stencilator/blob/main/documentation/example.gif?raw=true)

A tool that lets you generate the stencils to paint a QR code with two colors

# Original problem & usage example

I originally made this program for a friend, but I thought it would be nice to make it public.

# Disclaimer
Support is focused on Windows, but it probably works on Linux too.

# Installation
Download the latest zip file from [releases](https://github.com/80sVectorz/qr_code_stencilator/releases)
and extract it somewhere.
For now you'll need basic command line knowledge to use this program.
To get info on how to use the program use the help flag:
`qr_code_stencilator.exe --help`

# Future plans
Things I already plan to implement are:
- Support for more advanced instructions to create multiple version of a QR code in one go.
- A GUI version
82 changes: 54 additions & 28 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
import os
import sys
import PyInstaller.__main__
from pathlib import Path
import shutil

VERSION = sys.argv[-1]
DIST_PATH = f".\\dist\\qr_code_stencilator_{VERSION}"
VERSION_FILE = f'{DIST_PATH}\\VERSION.txt'

os.system(f'mkdir "{DIST_PATH}"')

try:
with open(VERSION_FILE,'w') as f:
f.write(VERSION)
except:
pass

os.system(f'attrib +h "{VERSION_FILE}"')

PyInstaller.__main__.run([
'./src/qr_code_stencilator/main.py',
'--onefile',
'--noconfirm',
'--nowindow',
'--name=qr_code_stencilator',
f'--distpath={DIST_PATH.replace('\\','/')}'
])

os.system(f'copy paper_formats.toml {DIST_PATH}')
os.system(f'mkdir {DIST_PATH}\\presets')
os.system(f'copy presets\\default.toml {DIST_PATH}\\presets')
os.system(f'copy presets\\example_preset.toml {DIST_PATH}\\presets')
os.system(f'mkdir {DIST_PATH}\\outputs')
def build(program_path:Path, dist_path:Path, version:str):
on_windows = (os.name == 'nt')

version_file = dist_path/'VERSION.txt'
if version_file.exists():
os.remove(version_file)

with open(version_file,'w') as f:
f.write(version)

PyInstaller.__main__.run([
'./src/qr_code_stencilator/main.py',
'--onefile',
'--noconfirm',
'--nowindow',
'--name=qr_code_stencilator',
f'--distpath={dist_path.as_posix()}'
])

shutil.copy2(program_path/'paper_formats.toml', dist_path)

presets_path = program_path/'presets/'
dist_presets_path = dist_path/'presets/'
dist_presets_path.mkdir(exist_ok=True)

shutil.copy2(presets_path/'default.toml', dist_presets_path)
shutil.copy2(presets_path/'example_preset.toml', dist_presets_path)

dist_outputs_path = dist_path/'outputs/'
dist_outputs_path.mkdir(exist_ok=True)

shutil.copy2(program_path/'README.md', dist_path)

documentation_path = program_path/'documentation/'
dist_documentation_path = dist_path/'documentation/'

shutil.copytree(documentation_path,dist_documentation_path, dirs_exist_ok=True)
shutil.rmtree(dist_documentation_path/'example_gif_frames/')

if on_windows:
os.system(f'attrib +h "{version_file}"')
os.system(f'attrib +h "{dist_presets_path/"default.toml"}"')

if __name__ == "__main__":
version = sys.argv[-1]

dist_path = Path(f'./dist/qr_code_stencilator_{version}')
dist_path.mkdir(parents=True,exist_ok=True)

program_path = Path(os.getcwd())

build(program_path, dist_path, version)
Binary file added documentation/example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72ba35b

Please sign in to comment.