Last active
January 16, 2016 10:52
-
-
Save b4dtR1p/f733492dc07e3a9475cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import csv | |
import tkinter | |
from tkinter.filedialog import askopenfilename | |
A = '' | |
B = '' | |
def close_window(): # destroying the main window | |
root.destroy() | |
def file_A(): # return file rif | |
globals()['A'] = askopenfilename() | |
def file_B(): | |
globals()['B'] = askopenfilename() | |
def diff(a, b): | |
b = set(b) | |
return [aa for aa in a if aa not in b] | |
def esegui(): | |
file1 = open(A, "r") | |
file2 = open(B, "r") | |
reader1 = csv.reader(file1, delimiter=';', quotechar=' ') | |
reader2 = csv.reader(file2, delimiter=';', quotechar=' ') | |
lista1 = [] | |
lista2 = [] | |
for row in reader1: | |
lista1.append(str(row[0])) | |
for row in reader2: | |
lista2.append(str(row[0])) | |
f = open("diff.txt","w+") | |
f.write("Telai che differiscono tra spunta e nave\n") | |
out = diff(lista2, lista1) or diff(lista1, lista2) | |
if len(out) == 0: | |
print('nothing to do') | |
exit() | |
else: | |
print('differenze') | |
for i in out: | |
print(i) | |
print(i, file=f) | |
f.close() | |
root = tkinter.Tk() | |
root.title("Comparatore di Telai") | |
root.withdraw() | |
root.update_idletasks() # Update "requested size" from geometry manager | |
x = (root.winfo_screenwidth() - root.winfo_reqwidth()) / 2 | |
y = (root.winfo_screenheight() - root.winfo_reqheight()) / 2 | |
root.geometry("+%d+%d" % (x, y)) | |
root.deiconify() | |
frame = tkinter.Frame(root) | |
frame.pack() | |
button_open_A = tkinter.Button(frame) | |
button_open_A['text'] = 'Seleziona la lista di sbarco' | |
button_open_A['command'] = file_A | |
button_open_A.pack() | |
button_open_B = tkinter.Button(frame) | |
button_open_B['text'] = 'Seleziona la spunta effettuata' | |
button_open_B['command'] = file_B | |
button_open_B.pack() | |
button_run = tkinter.Button(frame) | |
button_run['text'] = 'Compara le liste' | |
button_run['command'] = esegui | |
button_run.pack() | |
button_kill = tkinter.Button(frame) | |
button_kill['text'] ="Exit" | |
button_kill['command'] = close_window | |
button_kill.pack() | |
tkinter.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment