La til pdf eksport for startliste
This commit is contained in:
parent
2b22bcb7e1
commit
06dae8b35b
9
dev.py
9
dev.py
@ -7,9 +7,10 @@ from rich.table import Table
|
||||
|
||||
if __name__ == "__main__":
|
||||
event = otime.event(0, 'supercup')
|
||||
event.import_ttime_cnf('sc_2021_ttime/ttime.cnf.txt')
|
||||
event.import_ttime_db('sc_2021_ttime/db_eventor.csv')
|
||||
event.import_mtr_file('sc_2021_ttime/mtr.csv')
|
||||
event.import_ttime_cnf('k2ds/tt.cnf')
|
||||
event.import_ttime_db('k2ds/db.csv')
|
||||
event.import_mtr_file('k2ds/mtr.txt')
|
||||
#card_punches = otime.card_punch.list_from_mtr_f('sc_2021_ttime/mtr.csv')
|
||||
event.match_runners_cards()
|
||||
event.get_xml_res().write('Resultater.xml')
|
||||
event.create_start_list_pdf('starttimes.pdf')
|
||||
#event.get_xml_res().write('Resultater.xml')
|
||||
|
20
otime.py
20
otime.py
@ -3,6 +3,7 @@ import datetime
|
||||
import csv
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
from fpdf import FPDF
|
||||
|
||||
class event:
|
||||
def __init__(self, eventid, name, **kwargs):
|
||||
@ -127,6 +128,25 @@ class event:
|
||||
#</Class>
|
||||
ET.indent(root, space=' ', level=0)
|
||||
return tree
|
||||
|
||||
def create_start_list_pdf(self, file_name):
|
||||
pdf = FPDF()
|
||||
pdf.add_page()
|
||||
pdf.add_font("DejaVuSans", fname="/usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf")
|
||||
pdf.set_font("DejaVuSans", size=10)
|
||||
line_height = pdf.font_size * 2
|
||||
col_width = pdf.epw / 4 # distribute content evenly
|
||||
for runner in self.runners:
|
||||
pdf.multi_cell(col_width, line_height, runner.fullname(), border=1, ln=3, max_line_height=pdf.font_size, align='L')
|
||||
pdf.multi_cell(col_width, line_height, runner.o_class.name, border=1, ln=3, max_line_height=pdf.font_size)
|
||||
pdf.multi_cell(col_width, line_height, str(runner.card), border=1, ln=3, max_line_height=pdf.font_size)
|
||||
if runner.start_time != None:
|
||||
pdf.multi_cell(col_width, line_height, str(runner.start_time), border=1, ln=3, max_line_height=pdf.font_size)
|
||||
else:
|
||||
pdf.multi_cell(col_width, line_height, '', border=1, ln=3, max_line_height=pdf.font_size)
|
||||
pdf.ln(line_height)
|
||||
pdf.output(file_name)
|
||||
|
||||
class runner:
|
||||
def __init__(self, runner_id, first, last, club, country, card, o_class, start_time):
|
||||
self.id = runner_id
|
||||
|
Loading…
Reference in New Issue
Block a user