80 lines
3.5 KiB
Python
80 lines
3.5 KiB
Python
import tkinter as tk
|
|
import tkinter.ttk as ttk
|
|
import tkinter.filedialog as tkfiledialog
|
|
|
|
from trouver_decedes import trouver_decedes
|
|
|
|
class MainApplication(tk.Frame):
|
|
def __init__(self, parent, *args, **kwargs):
|
|
tk.Frame.__init__(self, parent, *args, **kwargs)
|
|
self.parent = parent
|
|
self.frame = tk.Frame(parent)
|
|
self.frame.pack()
|
|
|
|
# Sélection base INSEE
|
|
self.label_bdd_insee = tk.Label(self.frame, text="Fichier de l'INSEE")
|
|
self.label_bdd_insee.grid(row=0, column=0, sticky='e')
|
|
self.value_bdd_insee = tk.StringVar()
|
|
self.entry_bdd_insee = tk.Entry(self.frame, state='disabled', textvariable=self.value_bdd_insee)
|
|
self.entry_bdd_insee.grid(row=0, column=1, sticky='ew')
|
|
self.button_bdd_insee = tk.Button(self.frame, text="...", command=self.command_button_bdd_insee)
|
|
self.button_bdd_insee.grid(row=0, column=2, sticky='w')
|
|
|
|
# Sélection répertoire sortie
|
|
self.label_dir_out = tk.Label(self.frame, text="Répertoire de sortie")
|
|
self.label_dir_out.grid(row=1, column=0, sticky='e')
|
|
self.value_dir_out = tk.StringVar()
|
|
self.entry_dir_out = tk.Entry(self.frame, state='disabled', textvariable=self.value_dir_out)
|
|
self.entry_dir_out.grid(row=1, column=1, sticky='ew')
|
|
self.button_dir_out = tk.Button(self.frame, text="...", command=self.command_button_dir_out)
|
|
self.button_dir_out.grid(row=1, column=2, sticky='w')
|
|
|
|
# Sélection des unités à traiter
|
|
self.label_units = tk.Label(self.frame, text="Unités à purger")
|
|
self.label_units.grid(row=2, column=0, sticky='e')
|
|
self.value_units = tk.StringVar()
|
|
self.entry_units = tk.Entry(self.frame, textvariable=self.value_units)
|
|
self.entry_units.grid(row=2, column=1, sticky='ew', columnspan="2")
|
|
|
|
# Bouton validation
|
|
self.button_valid = tk.Button(self.frame, text="Ok", command=self.command_button_valid)
|
|
self.button_valid.grid(row=3, column=0, columnspan=3)
|
|
|
|
# Barre de progression
|
|
self.progressbar = ttk.Progressbar(self.frame, orient=tk.HORIZONTAL, mode='determinate')
|
|
self.progressbar.grid(row=4, column=0, columnspan=3, sticky='ew')
|
|
|
|
# Affichage des logs
|
|
self.text_log = tk.Text(self.frame, state='disabled')
|
|
self.text_log.grid(row=0, column=3, rowspan=5, sticky='nesw')
|
|
|
|
def command_button_bdd_insee(self):
|
|
self.value_bdd_insee.set(tkfiledialog.askopenfilename(title="Fichier de l'INSEE"))
|
|
|
|
def command_button_dir_out(self):
|
|
self.value_dir_out.set(tkfiledialog.askdirectory(title="Répertoire de sortie"))
|
|
|
|
def tracker(self, step=None, text=None, set_max=None):
|
|
if step:
|
|
self.progressbar.step(step)
|
|
elif text:
|
|
print(text)
|
|
self.text_log.configure(state='normal')
|
|
self.text_log.insert(tk.END, text)
|
|
self.text_log.configure(state='disabled')
|
|
elif set_max:
|
|
self.progressbar['maximum'] = set_max
|
|
|
|
def command_button_valid(self):
|
|
trouver_decedes(chemin_base_donnees=self.value_bdd_insee.get(),
|
|
chemin_repertoire_sortie=self.value_dir_out.get(),
|
|
numeros_unites=self.value_units.get().split(','),
|
|
tracker=self.tracker)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
root = tk.Tk()
|
|
root.title('Recherche des personnes décédées dans les registres')
|
|
MainApplication(root).pack(side="top", fill="both", expand=True)
|
|
root.mainloop()
|