Commit 774f0985 authored by matograine's avatar matograine

Add relative path for graphical objects

parent dd92dfc7
......@@ -2,8 +2,16 @@
# DO NOT USE IT FOR STRONG CRYPTOGRAPHIC PURPOSE!
from random import choice
import sys
import os
def diceware(N, wordlist="objects/wordlist.txt", separator="", camelcase=True):
# set the wordlist path
wordlist = "objects/wordlist.txt"
parent_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
wordlist_path = os.path.join(parent_dir, wordlist)
def diceware(N, wordlist=wordlist_path, separator="", camelcase=True):
with open(wordlist, "r") as f:
words = f.read().split('\n')
out = []
......
......@@ -10,6 +10,9 @@ import json
import qrcode
import datetime
recto_file = "objects/recto.png"
verso_file = "objects/verso.png"
typo_file = "objects/Roboto-Medium.ttf"
class Generator:
"""Generate some wallets, create the pdf to print"""
......@@ -22,6 +25,13 @@ class Generator:
self.date = date
self.c = None
# set objects dir
par_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
#wordlist_path = os.path.join(parent_dir, wordlist)
self.recto = os.path.join(par_dir, recto_file)
self.verso = os.path.join(par_dir, verso_file)
self.typo = os.path.join(par_dir, typo_file)
def generate(self):
"""
generate tips wallets ; then create the pdf file
......@@ -53,13 +63,14 @@ class Generator:
qr_pub = qrcode.make(account_url)
qr_priv = qrcode.make(wif_data)
# Open images
recto = Image.open("objects/recto.png")
verso = Image.open("objects/verso.png")
recto = Image.open(self.recto)
verso = Image.open(self.verso)
# Pasting QR codes
recto.paste(qr_pub.resize((200, 200)), (435, 15)) # 36))
verso.paste(qr_priv.resize((180, 180)), (580, 6))
# Setting font
font = ImageFont.truetype("objects/Roboto-Medium.ttf", 18)
# font = ImageFont.truetype("objects/Roboto-Medium.ttf", 18)
font = ImageFont.truetype(self.typo, 18)
# Writing amount
if self.amount > 0:
draw = ImageDraw.Draw(recto)
......@@ -68,7 +79,7 @@ class Generator:
(1090, 150),
txt,
(0, 0, 0),
font=ImageFont.truetype("objects/Roboto-Medium.ttf", 30),
font=ImageFont.truetype(self.typo, 30),
)
# Writing date
write_date = "{0}/{1}/{2}".format(self.date.day, self.date.month, self.date.year)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment