|
| 1 | +from tkinter import * |
| 2 | +from fpdf import FPDF |
| 3 | +import webbrowser |
| 4 | + |
| 5 | +def generate_quote(): |
| 6 | + description = entry_description.get() |
| 7 | + estimated_hours = entry_hours.get() |
| 8 | + hourly_rate = entry_hourly_rate.get().replace(",", ".") # Replace commas with dots |
| 9 | + deadline = entry_deadline.get() |
| 10 | + |
| 11 | + total_amount = float(estimated_hours) * float(hourly_rate) |
| 12 | + |
| 13 | + # Generating PDF |
| 14 | + pdf = FPDF() |
| 15 | + pdf.add_page() |
| 16 | + pdf.set_font("Arial") |
| 17 | + |
| 18 | + # PDF coordinates/path |
| 19 | + pdf.image("template.png", x=0, y=0) |
| 20 | + pdf.text(115, 145, description) |
| 21 | + pdf.text(115, 160, estimated_hours) |
| 22 | + pdf.text(115, 175, hourly_rate) |
| 23 | + pdf.text(115, 190, deadline) |
| 24 | + pdf.text(115, 205, str(total_amount)) |
| 25 | + |
| 26 | + pdf_file_path = "Quote.pdf" |
| 27 | + pdf.output(pdf_file_path) |
| 28 | + print("Quote generated successfully") |
| 29 | + |
| 30 | + # Open the file in the web browser |
| 31 | + webbrowser.open(pdf_file_path) |
| 32 | + |
| 33 | +# Configuring the graphical interface |
| 34 | +root = Tk() |
| 35 | +root.title("Quote Generator") |
| 36 | + |
| 37 | +# Increasing the window size |
| 38 | +root.geometry("600x400") |
| 39 | + |
| 40 | +label_description = Label(root, text="Project description:", font=("Arial", 12)) |
| 41 | +label_description.grid(row=0, column=0, pady=10, padx=10) |
| 42 | +entry_description = Entry(root, font=("Arial", 12)) |
| 43 | +entry_description.grid(row=0, column=1, pady=10, padx=10) |
| 44 | + |
| 45 | +label_hours = Label(root, text="Estimated hours:", font=("Arial", 12)) |
| 46 | +label_hours.grid(row=1, column=0, pady=10, padx=10) |
| 47 | +entry_hours = Entry(root, font=("Arial", 12)) |
| 48 | +entry_hours.grid(row=1, column=1, pady=10, padx=10) |
| 49 | + |
| 50 | +label_hourly_rate = Label(root, text="Hourly rate:", font=("Arial", 12)) |
| 51 | +label_hourly_rate.grid(row=2, column=0, pady=10, padx=10) |
| 52 | +entry_hourly_rate = Entry(root, font=("Arial", 12)) |
| 53 | +entry_hourly_rate.grid(row=2, column=1, pady=10, padx=10) |
| 54 | + |
| 55 | +label_deadline = Label(root, text="Estimated deadline in days:", font=("Arial", 12)) |
| 56 | +label_deadline.grid(row=3, column=0, pady=10, padx=10) |
| 57 | +entry_deadline = Entry(root, font=("Arial", 12)) |
| 58 | +entry_deadline.grid(row=3, column=1, pady=10, padx=10) |
| 59 | + |
| 60 | +button_generate = Button(root, text="Generate Quote", command=generate_quote, font=("Arial", 12)) |
| 61 | +button_generate.grid(row=4, columnspan=2, pady=20) |
| 62 | + |
| 63 | +root.mainloop() |
0 commit comments