-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainWindow.py
More file actions
170 lines (122 loc) · 5.35 KB
/
MainWindow.py
File metadata and controls
170 lines (122 loc) · 5.35 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# -*- coding: utf-8 -*-
'''This file implements the menu frame of the GUI for the ivctrack module
'''
__author__ = ' De Almeida Luis <ldealmei@ulb.ac.be>'
#------generic imports------
from Tkinter import *
import tkFileDialog
#-------local imports------
from TrackingFrame import TrackingFrame
from PlotFrame import PlotFrame
from AniFrame import AniFrame
from MeasFrameV3 import MeasFrameV3
class MainFrame(Frame):
"""Main menu frame : The user can either start a new tracking or view results from previous trackings
The .zip file which contains the image sequences is linked to the menu window and can only be modified from there"""
def __init__(self,win):
Frame.__init__(self,win,width=700,height=700)
self.pack()
self.track_frame=None
self.plot_frame=None
self.meas_frame=None
self.ani_frame=None
self.menu_buttons=[]
self.datazip_filename=""
self.file_opt={}
self.file_opt['filetypes'] = [('ZIP file','.zip')]
self.file_opt['defaultextension'] ='.zip'
self.file_opt['title'] = 'Select a zipped sequence file'
#----------------------------------------------------GUI IMPLEMENTATION-----------------------------------------
self.track_button=Button(self,text='Start Tracking',command=lambda : self.track())
self.track_button.pack(fill='both')
self.menu_buttons.append(self.track_button)
self.plot_button=Button(self,text='Plot Results',command=lambda : self.plot())
self.plot_button.pack(fill='both')
self.menu_buttons.append(self.plot_button)
self.meas_button=Button(self,text='Measurements',command=lambda : self.measurements())
self.meas_button.pack(fill='both')
self.menu_buttons.append(self.meas_button)
self.ani_button=Button(self,text='Player',command=lambda : self.play())
self.ani_button.pack(fill='both')
self.menu_buttons.append(self.ani_button)
self.zip_var=StringVar()
self.change_zip_button=Button(self,textvariable=self.zip_var,command= lambda : self.change_zip())
self.menu_buttons.append(self.change_zip_button)
self.quit_button=Button(self,text='Quit',command=win.quit)
self.quit_button.pack(fill='both')
self.menu_buttons.append(self.quit_button)
self.back_button=Button(self,text='Back',command = lambda : self.back())
#------------------------------------------------------END-------------------------------------------------------------
def back(self):
"""Return to the menu window. """
try :
self.track_frame.pack_forget()
self.track_frame=None
except:
pass
try :
self.plot_frame.pack_forget()
self.plot_frame=None
except:
pass
try :
self.meas_frame.pack_forget()
self.meas_frame=None
except:
pass
try:
self.ani_frame.pack_forget()
self.ani_frame=None
except:
pass
self.back_button.pack_forget()
for button in self.menu_buttons:
button.pack(fill='both')
def track(self):
"""Method that transits from the menu to the tracking frame """
if self.datazip_filename=="":
self.change_zip()
self.track_frame=TrackingFrame(win,self.datazip_filename)
self.track_frame.pack()
for button in self.menu_buttons:
button.pack_forget()
self.back_button.pack(side='bottom')
def plot(self):
"""Method that transits from the menu to the plotting frame """
if self.datazip_filename=="":
self.change_zip()
self.plot_frame=PlotFrame(win,self.datazip_filename)
self.plot_frame.pack()
for button in self.menu_buttons:
button.pack_forget()
self.back_button.pack(side='bottom')
def measurements(self):
"""Method that transits from the menu to the frame that displays multiple measures"""
if self.datazip_filename=="":
self.change_zip()
self.meas_frame=MeasFrameV3(win,self.datazip_filename)
self.meas_frame.pack()
for button in self.menu_buttons:
button.pack_forget()
self.back_button.pack(side='bottom')
def play(self):
"""Method that transits from the menu to the frame that plays the tracking and allows to save it to .mp4"""
if self.datazip_filename=="":
self.change_zip()
self.ani_frame=AniFrame(win,self.datazip_filename)
self.ani_frame.pack()
for button in self.menu_buttons:
button.pack_forget()
self.back_button.pack(side='bottom')
def change_zip(self):
"""Method that allows the user to change the current sequence ZIP file """
self.datazip_filename=tkFileDialog.askopenfilename(**self.file_opt)
try:
self.zip_var.set("Change Zip File ({})".format(self.datazip_filename.rsplit('/')[-1]))
except AttributeError:
pass
if __name__== '__main__':
win=Tk()
win.wm_title('IVCTrack GUI')
root=MainFrame(win)
root.mainloop()