-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.py
69 lines (55 loc) · 1.61 KB
/
view.py
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
67
68
69
"""A simple desktop application that takes user input and print on the screen.
Task:
- Create an input field
- Create a button to process the user input
- Print user input to create.
Algorithm:
- Create the input widget(Entry)
- Create a button widget that processes the user input when the button is clicked.
- Create a function that processes the button when it's clicked.
-
"""
from tkinter import *
import main
from tkinter import filedialog
import glob
import os
# create the root widget
root = Tk()
root.geometry("400x400")
# get file to ping
def start_process():
file_name = filedialog.askopenfilename()
# run the main function to process the file
main.run(file_name)
# display the result
display_result()
def display_result():
# open the result file
list_of_files = glob.glob('Result/*')
latest_file = max(list_of_files, key=os.path.getctime)
result_file = open(latest_file , "r")
result_text = result_file.read()
result_file.close()
result_Label = Label(
root,
text=result_text,
)
# result_Label.grid(row=7, column=7, padx=10)
result_Label.place(relx = 0.5, rely = 0.5,anchor = 'center')
print(result_Label)
file_label = Label(
root,
text='Upload a CSV file '
)
file_label.grid(row=0, column=0, padx=10)
get_fileBtn = Button(
root,
text ='Choose File',
command = lambda: start_process()
)
get_fileBtn.grid(row=0, column=1)
# result_label = Label(root, text='Result')
# result_label.grid(row=1, column=0, padx=10)
# create a loop that constantly run to keep the window open.
root.mainloop()