-
Notifications
You must be signed in to change notification settings - Fork 0
/
dryvr_gui.py
88 lines (70 loc) · 2.99 KB
/
dryvr_gui.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# GUI for DryVR
# Ver 0
# Provides Graphical Environment to enter input and get the verification results back graphically
import sys, os
from Tkinter import *
class Application(Frame):
# Initialize MainFrame
def __init__(self, master=None):
Frame.__init__(self, master)
self.init_vars()
self.create_widgets()
self.display()
def init_vars(self):
self.gen_flag = 0 # flag variable to prevent repetitive work
self.oldfilename = StringVar() # stores old filename to prevent repetitive work
self.message = StringVar() # message to display to UI after verification
self.v1 = StringVar() # filename
# set it to some value
self.v1.set("Enter input file name")
def create_widgets(self):
# Quit Button
self.QUIT = Button(self, text='Quit', fg="blue", bg="white", command=self.quit)
self.QUIT.bind('<Enter>', lambda e: self.QUIT.configure(activeforeground="white", activebackground="blue"))
# Generate Button
self.GENERATE = Button(self, text="Generate", command=self.generate_graph)
# Label to display output
self.message_label = Label(self, text=self.message)
# Canvas for graph
self.cv = Canvas()
# Input interface for filename of file containing data to verify
self.file_entry = Entry(textvariable = self.v1)
self.file_entry.bind('<Key-Return>', self.process)
# for debudding
def print_contents(self, event):
print "hi. contents of entry is now ---->", \
self.v1.get()
def process(self, event):
filename = self.v1.get()
if self.oldfilename != filename:
os.system('python main.py inputFile/' + filename)
self.gen_flag = 1;
self.display_op()
self.oldfilename = filename
def generate_graph(self):
if self.gen_flag == 1:
self.graph = PhotoImage(file = r"curgraph.png")
self.cv.create_image(10, 10, image=self.graph, anchor='nw')
self.gen_flag = 0
else:
pass
def display_op(self):
f = open('output/verification.txt', 'r')
self.message = f.readline() + f.readline() + f.readline() + f.readline()
f.close()
# now message_label gets updated to show corresponding output
def display(self):
self.grid()
self.QUIT.grid(row=0, column=3)
self.GENERATE.grid(row=0, column=2)
self.cv.grid(row=1, column=0)
#self.cv.pack(side='top', fill='both', expand='yes')
self.message_label.grid(row=1, column=2)
self.file_entry.grid(row=0, column=1)
################################################################################
root = Tk()
app = Application(master=root)
app.master.minsize(1000, 400)
app.mainloop()
#root.destroy()