Completed
Push — master ( 8667a3...9631f8 )
by Sepand
22s
created

open_folder()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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