-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuser_interface.py
More file actions
137 lines (113 loc) · 5.45 KB
/
user_interface.py
File metadata and controls
137 lines (113 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
from tkinter import *
from tkinter import ttk, filedialog, simpledialog
from tkinter.font import Font
import xlrd as xl
from afm_recognise import *
from tkinter import messagebox as mb
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
window = Tk()
pdf_file_name = ''
csv_file_name = ''
def choose_csv_file():
global csv_file_name
csv_file_name = filedialog.askopenfilename(initialdir="/", title="Επιλογή Πελατολογίου", filetypes=(("Excel Files (.xls)", "*.xls"),("Excel Files (.xlsx)", "*.xlsx"), ("All Files", "*.*")))
csv_textbox.config(state="normal")
csv_textbox.delete('1.0', END)
csv_textbox.insert(INSERT, csv_file_name)
csv_textbox.config(state="disabled")
wb = xl.open_workbook(csv_file_name)
s1 = wb.sheet_by_index(0)
s1.cell_value(0, 0)
csv_counter.config(state="normal")
csv_counter.delete(1.0, END)
csv_counter.insert(INSERT, s1.nrows)
csv_counter.config(state="disabled")
def choose_pdf_file():
global pdf_file_name
pdf_file_name = filedialog.askopenfilename(initialdir="/", title="Επιλογή Τιμολογίων", filetypes=(("PDF Files (.pdf)", "*.pdf"), ("All Files", "*.*")))
pdf_textbox.config(state="normal")
pdf_textbox.delete(1.0, END)
pdf_textbox.insert(INSERT, pdf_file_name)
pdf_textbox.config(state="disabled")
with open(pdf_file_name, "rb") as pdf_file:
pdf_reader = PdfFileReader(pdf_file)
pdf_counter.config(state="normal")
pdf_counter.delete(1.0, END)
pdf_counter.insert(INSERT, pdf_reader.numPages)
pdf_counter.config(state="disabled")
def check_csv(csv_path):
if os.path.isfile(csv_path):
return True
else:
return False
def check_pdf(pdf_path):
if os.path.isfile(pdf_path):
return True
else:
return False
def send_btn():
# Check if CSV file has inserted
if (check_csv(csv_file_name)):
# CSV file inserted
# Check if PDF file has inserted
if (check_pdf(pdf_file_name)):
# PDF file inserted
subject = simpledialog.askstring("ΤΟ ΘΕΜΑ ΤΟΥ e-mail.", "ΠΑΡΑΚΑΛΩ ΠΛΗΚΤΡΟΛΟΓΗΣΤΕ ΤΟ ΘΕΜΑ ΤΟΥ e-mail.")
body = simpledialog.askstring("ΤΟ ΚΥΡΙΩΣ ΚΕΙΜΕΝΟ ΤΟΥ e-mail.",
"ΠΑΡΑΚΑΛΩ ΠΛΗΚΤΡΟΛΟΓΗΣΤΕ ΤΟ ΚΥΡΙΩΣ ΚΕΙΜΕΝΟ ΤΟΥ e-mail.")
main_program(pdf_file_name, csv_file_name, subject, body)
mb.showinfo('Επιτυχία', 'Το πρόγραμμα ολοκληρώθηκε με επιτυχία.')
else:
mb.showinfo('Σφάλμα', 'Δεν έχει εισάγει αρχείο τιμολογίων.')
else:
mb.showinfo('Σφάλμα', 'Δεν έχει εισάγει αρχείο πελατολογίου.')
window.title("ΑΠΟΣΤΟΛΗ ΤΙΜΟΛΟΓΙΩΝ")
canvas = Canvas(window, width=525, height=150)
canvas.pack()
separator = ttk.Separator(window, orient='horizontal')
separator.pack(side='top', fill='x')
choose_text = canvas.create_text(260, 140, text="Eπιλογή Αρχείων", fill="#652828", anchor=CENTER)
myFont = Font(family="Futura", size=11)
csv_textbox = Text(window, height=1.25, width=132, bg="light yellow")
csv_textbox.place(rely=0.35, relx=0.02, x=0, y=0, anchor=W)
csv_textbox.insert(INSERT, "Επιλογή Αρχείου")
csv_textbox.configure(font=myFont)
csv_textbox.config(state="disabled")
choose_csv_btn = Button(window, text ="Επιλογή Πελατολογίου", command=choose_csv_file)
choose_csv_btn.place(rely=0.35, relx=0.915, x=0, y=0, anchor=CENTER)
pdf_textbox = Text(window, height=1.25, width=132, bg="light yellow")
pdf_textbox.place(rely=0.50, relx=0.02, x=0, y=0, anchor=W)
pdf_textbox.insert(INSERT, "Επιλογή Αρχείου")
pdf_textbox.configure(font=myFont)
pdf_textbox.config(state="disabled")
choose_pdf_btn = Button(window, text =" Επιλογή Τιμολογίων ", command=choose_pdf_file)
choose_pdf_btn.place(rely=0.50, relx=0.915, x=0, y=0, anchor=CENTER)
csv_counter_text_box = Text(window, height=1.25, width=19, bg="white")
csv_counter_text_box.place(rely=0.6, relx=0.77, x=0, y=0, anchor=W)
csv_counter_text_box.insert(INSERT, "Επιλεγμένοι Πελάτες: ")
csv_counter_text_box.configure(font=myFont)
csv_counter_text_box.config(state="disabled")
csv_counter = Text(window, height=1.25, width=10, bg="white")
csv_counter.place(rely=0.6, relx=0.97, x=0, y=0, anchor=E)
csv_counter.insert(INSERT, "")
csv_counter.configure(font=myFont)
csv_counter.config(state="disabled")
pdf_counter_text_box = Text(window, height=1.25, width=19, bg="white")
pdf_counter_text_box.place(rely=0.7, relx=0.77, x=0, y=0, anchor=W)
pdf_counter_text_box.insert(INSERT, "Επιλεγμένα Τιμολόγια:")
pdf_counter_text_box.configure(font=myFont)
pdf_counter_text_box.config(state="disabled")
pdf_counter = Text(window, height=1.25, width=10, bg="white")
pdf_counter.place(rely=0.7, relx=0.97, x=0, y=0, anchor=E)
pdf_counter.insert(INSERT, "")
pdf_counter.configure(font=myFont)
pdf_counter.config(state="disabled")
send_btn = Button(window, text="ΑΠΟΣΤΟΛΗ", command=send_btn)
send_btn.place(rely=0.8, relx=0.5, x=0, y=0, anchor=CENTER)
send_btn.config(height=3, width=17)
exit_btn = Button(window, text="ΕΞΟΔΟΣ", command=window.destroy)
exit_btn.place(rely=0.9, relx=0.5, x=0, y=0, anchor=CENTER)
window.geometry("1280x600")
window.resizable(0, 0)
window.mainloop()