Skip to content

Commit

Permalink
fix fpdf paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ciszko committed Oct 8, 2020
1 parent 97c175c commit b9ff9ef
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from employee import *
from menu import *

BASEDIR = os.path.dirname(os.path.realpath(__file__))

class App(Tk):
def __init__(self, *kwargs, **args):
Tk.__init__(self)
Expand All @@ -25,15 +27,13 @@ def __init__(self, *kwargs, **args):
kasia = 'fajna'

self.option_add("*Font", "Arial 8") # default font
self.iconbitmap(r"./data/ikonka.ico") # window icon
self.iconbitmap(os.path.join(BASEDIR, "data/ikonka.ico")) # window icon
self.menu = My_Menu(self, controller=self, background = self.bg)
self.config(background = self.bg, menu = self.menu)
self.protocol("WM_DELETE_WINDOW", self.on_exit)
self.grid_propagate(True)
self.title("Ewidencja czasu pracy")



container = ttk.Frame(self)
container.grid(row=0, column = 0, sticky=NSEW)
#container.pack(side="top", fill="both", expand=True)
Expand Down Expand Up @@ -237,10 +237,10 @@ def to_print(self):
pdf = FPDF('L', 'mm', 'A4')

try:
pdf.add_font("./data/DejaVuSans", "", "DejaVuSans.ttf", uni=True)
pdf.add_font('DejaVuSans', "", os.path.join(BASEDIR, "data/DejaVuSans.ttf"), uni=True)
except Exception as e:
messagebox.showerror("Błąd", e)
pdf.set_font("./data/DejaVuSans", size=11)
pdf.set_font("DejaVuSans", size=10)

pdf.add_page()

Expand Down Expand Up @@ -364,14 +364,14 @@ def on_init(self, type = "work"):

# check if the file exists, if not then make one
current_year = page.month.selected_year.get()
if not os.path.isfile('./Roczne podsumowanie/' + str(current_year) + ".json"):
if not os.path.isfile(os.path.join(BASEDIR,'Roczne podsumowanie', (str(current_year) + ".json"))):
# create a new dict
summary = {
"employees" : {}
}
names = []
# iterate over employees
for file in sorted(os.listdir("./Pracownicy")):
for file in sorted(os.listdir(os.path.join(BASEDIR, "Pracownicy"))):
names.append(str(file))

for name in names:
Expand All @@ -382,11 +382,11 @@ def on_init(self, type = "work"):
str("holiday_left_" + str(current_year - 1)) : 0,
str("holiday_left_" + str(current_year - 2)) : 0,
}
with open('./Roczne Podsumowanie/' + str(current_year) + ".json", 'w') as to_save:
with open(os.path.join(BASEDIR, 'Roczne Podsumowanie', (str(current_year) + ".json")), 'w') as to_save:
json.dump(summary, to_save, indent=4, ensure_ascii=False)


with open('./Roczne podsumowanie/' + str(current_year) + ".json", "r") as f1:
with open(os.path.join(BASEDIR, 'Roczne Podsumowanie', (str(current_year) + ".json")), "r") as f1:
x = json.load(f1)

row = 1
Expand Down Expand Up @@ -533,8 +533,8 @@ def to_pdf(self):
x = []
pdf = FPDF('P', 'mm', 'A4')

pdf.add_font("./data/DejaVuSans", "", "DejaVuSans.ttf", uni=True)
pdf.set_font("./data/DejaVuSans", size=10)
pdf.add_font('DejaVuSans', "", os.path.join(BASEDIR, "data/DejaVuSans.ttf"), uni=True)
pdf.set_font("DejaVuSans", size=10)
pdf.set_left_margin(16)

pdf.add_page()
Expand Down

0 comments on commit b9ff9ef

Please sign in to comment.