tkinter_exit()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
c 1
b 0
f 1
dl 0
loc 6
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
import sys
8
9
filename=""
10
def command_line(filename):
11
    time_1 = time.perf_counter()
12
    counter = csv_reader(filename)
13
    time_2 = time.perf_counter()
14
    delta_time = time_2 - time_1
15
    if counter != None:
16
        print(str(counter) + " VCF File Generated In " + time_convert(delta_time))
17
18
if __name__=="__main__":
19
    def open_folder(address):
20
        '''
21
        This function open file directory
22
        :param address: address of file
23
        :type address:str
24
        :return: None
25
        '''
26
        try:
27
            os.system("start "+address)
28
        except Exception:
29
            print("Error In Opening Final File")
30
    def openfile():
31
        '''
32
        This function ask for opening file with tkinter
33
        :return: filename as str
34
        '''
35
        global filename
36
        filename = askopenfilename(filetypes=(("CSV File", "*.csv")
37
                                              , ("Text File", "*.txt")
38
                                              ))
39
        folder=os.path.dirname(filename)
40
        time_1 = time.perf_counter()
41
        counter = csv_reader(filename,GUI=True)
42
        time_2 = time.perf_counter()
43
        delta_time = time_2 - time_1
44
        if counter!=None:
45
            print(str(counter) + " VCF File Generated In " + time_convert(delta_time))
46
            messagebox.showinfo("CSV2VCF",str(counter) + " VCF File Generated In " + time_convert(delta_time))
47
            open_folder(folder)
48
        return filename
49
50
    def tkinter_exit():
51
        '''
52
        This function quit tkinter windows
53
        :return: None
54
        '''
55
        root.quit()
56
    args=sys.argv
57
    if len(args)>1:
58
        command_line(args[1])
59
    else:
60
        root = Tk()
61
        root.overrideredirect(True)
62
        w = 400  # width for the Tk root
63
        h = 430  # height for the Tk root
64
        ws = root.winfo_screenwidth()  # width of the screen
65
        hs = root.winfo_screenheight()  # height of the screen
66
        x = (ws / 2) - (w / 2)
67
        y = (hs / 2) - (h / 2)
68
        root.geometry('%dx%d+%d+%d' % (w, h, x, y))
69
        root.wm_title("CSV2VCF")
70
        label_1=Label(root,text="CSV2VCF",font=("arial", 30, "bold")).pack()
71
        label_2=Label(root,text="By Moduland",font=("arial", 22, "bold")).pack()
72
        b = Button(root, text="Open File", bg="gray40", fg="blue", font=("arial", 22, "bold"),width=10,height=3, command=openfile).pack(
73
            padx="12", pady="12")
74
        i = Button(root, text="Exit", bg="gray40", fg="blue", font=("arial", 22, "bold"), width=10, height=3,
75
               command=tkinter_exit).pack(
76
            padx="12", pady="12")
77
        root.mainloop()
78