Completed
Push — master ( 727e1b...f3c3ed )
by Sepand
24s
created

tkinter_exit()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
import time
3
from VCF import *
4
from tkinter.filedialog import askopenfilename
5
from tkinter import *
6
import os
7
8
filename=""
9
10
if __name__=="__main__":
11
    root = Tk()
12
    root.overrideredirect(True)
13
    w = 400  # width for the Tk root
14
    h = 430  # height for the Tk root
15
    ws = root.winfo_screenwidth()  # width of the screen
16
    hs = root.winfo_screenheight()  # height of the screen
17
    x = (ws / 2) - (w / 2)
18
    y = (hs / 2) - (h / 2)
19
    root.geometry('%dx%d+%d+%d' % (w, h, x, y))
20
    def open_folder(address):
21
        try:
22
            os.system("start "+address)
23
        except Exception:
24
            print("Error In Opening Final File")
25
    def openfile():
26
        global filename
27
        filename = askopenfilename(filetypes=(("CSV File", "*.csv")
28
                                              , ("Text File", "*.txt")
29
                                              ))
30
        folder=os.path.dirname(filename)
31
        time_1 = time.perf_counter()
32
        counter = csv_reader(filename)
33
        time_2 = time.perf_counter()
34
        delta_time = time_2 - time_1
35
        if counter!=None:
36
            print(str(counter) + " VCF File Generated In " + time_convert(delta_time))
37
            messagebox.showinfo("CSV2VCF",str(counter) + " VCF File Generated In " + time_convert(delta_time))
38
            open_folder(folder)
39
        return filename
40
41
    def tkinter_exit():
42
        root.quit()
43
    root.wm_title("CSV2VCF")
44
    label_1=Label(root,text="CSV2VCF",font=("arial", 30, "bold")).pack()
45
    label_2=Label(root,text="By Moduland",font=("arial", 22, "bold")).pack()
46
    b = Button(root, text="Open File", bg="gray40", fg="blue", font=("arial", 22, "bold"),width=10,height=3, command=openfile).pack(
47
        padx="12", pady="12")
48
    i = Button(root, text="Exit", bg="gray40", fg="blue", font=("arial", 22, "bold"), width=10, height=3,
49
               command=tkinter_exit).pack(
50
        padx="12", pady="12")
51
    root.mainloop()
52