-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainMenu.py
103 lines (78 loc) · 3.12 KB
/
mainMenu.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/python
from Tkinter import *
from ttk import Treeview
from TestEntry import *
from HardwareTestGUIs import *
class GUIMainMenu(Frame):
"""Main menu for test of Genesi i.MX53 systems"""
def __init__(self,master=None):
"""Initialize the base class"""
Frame.__init__(self,master)
"""Set window title"""
self.master.title("Select System Test")
"""System Tests"""
self.createTestEntries()
"""Constants"""
self.TEST_COL=0
self.STATUS_COL=1
self.TEXT_ROW=0
self.TREEVIEW_ROW=1
self.BUTTON_ROW=2
"""Display main window with padding"""
self.grid()
self.createWidgets()
def createTestEntries(self):
#TODO must be a better way. Pickle?
self.tests = [TestInfo("Audio", AudioGUI), TestInfo("Clock", Dummy1),
TestInfo("Display", Dummy1), TestInfo("Keyboard", Dummy1),
TestInfo("Network", Dummy1), TestInfo("SSD", Dummy2),
TestInfo("Video", VideoGUI)]
self.testsLookup = {}
for te in self.tests:
self.testsLookup.update({te.name : te})
def createWidgets(self):
"""Create all the initial widgets for this menu"""
"""Labels"""
lbl = Label(self, text="Select test below", justify=LEFT)
lbl.grid(row=self.TEXT_ROW, column=self.TEST_COL)
"""Tests"""
self.trv = Treeview(self, columns=("Status"), displaycolumns='#all')
for test in self.tests:
treeviewInsertTest(self.trv, test)
self.trv.column('#0', width=100)
self.trv.heading('#0', text="Test")
self.trv.heading('Status', text='Status')
self.trv.grid(column=self.TEST_COL, row=self.TREEVIEW_ROW,
columnspan=2)
"""Buttons"""
self.btnOK = Button(self, text="OK", command=self.launchTest)
self.btnOK.grid(row=self.BUTTON_ROW, column=0)
self.btnQuit = Button(self, text="Quit", command=self.quit)
self.btnQuit.grid(row=self.BUTTON_ROW, column=1)
def launchTest(self):
# get the item in focus
testItem = self.trv.item(self.trv.focus())
if not testItem['text'] == '':
testInfo = self.testsLookup[testItem['text']]
testInfo.launchTest(self)
def processResults(self, testInfo):
self.trv.item(testInfo.name, values=(testInfo.status),
tags=(testInfo.status))
# update color notifications
self.trv.tag_configure('Success', foreground='green')
self.trv.tag_configure('Failure', foreground='red')
self.deiconify()
def withdraw(self):
"""Helpful function to hide window"""
self.master.withdraw()
def deiconify(self):
"""Helpful function to restore window"""
self.master.deiconify()
def treeviewInsertTest(trv, testInfo, pos='end'):
"""Add test to Treeview widget"""
trv.insert("", pos, iid=testInfo.name,
text=testInfo.name, values=(testInfo.status))
if __name__ == "__main__":
root = Tk()
mainMenu = GUIMainMenu(root)
root.mainloop()