-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexecute.pyw
66 lines (50 loc) · 2.39 KB
/
execute.pyw
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
import tkinter as tk
from tkinter import messagebox as mb
from tkinter.filedialog import askopenfilename, asksaveasfilename
from ris_conv import RISConv
class Program:
def __init__(self) -> None:
self.input_file_path = None
self.output_file_path = None
self.window = tk.Tk()
self.window.title('RIS2CSV')
self.window.geometry('450x80+600+400')
self.window.resizable(False, False)
icon_folder = tk.PhotoImage(file='../resources/icon_folder.png')
self.bt_open_file = tk.Button(self.window, borderwidth=0, image=icon_folder, cursor='hand2', command=self.open_file)
self.bt_open_file.grid(row=0, column=1, padx=10)
icon_save = tk.PhotoImage(file='../resources/icon_save.png')
self.bt_save = tk.Button(image=icon_save, borderwidth=0, state='disable', command=self.save_file)
self.bt_save.grid(row=0, column=2, padx=10)
self.lbinfo = tk.Label()
self.lbinfo.place(x=10, y=35)
self.lbsts = tk.Label(text='Aguardando seleção')
self.lbsts.place(x=10, y=60)
self.lbcopy = tk.Label(text='RIS2CSV © 2022 Wesley Dias')
self.lbcopy.place(x=250, y=60)
self.window.mainloop()
def open_file(self) -> None:
self.input_file_path = askopenfilename(filetypes=[('RIS File', '*.ris')])
if self.input_file_path:
self.lbinfo['text'] = self.input_file_path
self.lbsts['text'] = 'Pronto para converter e salvar'
self.bt_save['state'] = 'normal'
self.bt_save['cursor'] = 'hand2'
def save_file(self) -> None:
self.output_file_path = asksaveasfilename(filetypes=[('CSV File', '*.csv')])
if self.output_file_path:
self.lbsts['text'] = 'Convertendo arquivo, aguarde'
self.window.update()
try:
reader = RISConv(self.input_file_path)
reader.ris_to_csv(self.output_file_path)
except Exception as e:
self.lbsts['text'] = 'Erro ao converter arquivo'
mb.showerror('Erro', 'Tivemos problemas ao tentar converter e salvar o arquivo!')
print(e)
else:
self.lbsts['text'] = 'Sucesso ao converter arquivo'
mb.showinfo('Sucesso', f'Arquivo convertido para CSV e salvo com sucesso!')
self.window.update()
if __name__ == '__main__':
Program()