-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeaconGUI.py
50 lines (37 loc) · 1.33 KB
/
beaconGUI.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
import tkinter as tk
import openpyxl
from openpyxl.cell import get_column_letter
import itertools
import re
# TODO Have this initialization stuff in a class, only created once
# TODO Add a way to update information with most recent beacon
# Pull from database? Could show that whole chain works
def getColVals(indices):
listOut = []
for row in sheet[indices[0]:indices[1]]:
for obj in row:
listOut.append(obj.value)
return listOut
telemetryDef = 'MCGSmain/BeaconDefinition.xlsx'
wb = openpyxl.load_workbook(telemetryDef)
sheetList = wb.get_sheet_names()
sheet = wb.get_sheet_by_name(sheetList[0])
maxRow = sheet.max_row
maxCol = sheet.max_column
firstCol = getColVals(('A2','A'+str(maxRow)))
firstCol.sort()
# Grouping all variables by the first 4 letters
headers = {k: list(v) for k, v in itertools.groupby(firstCol, key=lambda x: x[0:4])}
groups = []
root = tk.Tk()
headerRe = re.compile('[\W_]+') # Regex removes underscore from first 4 chars, ex: GPS_ -> GPS
handles = {}
for header in headers.keys():
groups.append(tk.LabelFrame(root, text=headerRe.sub('',header), padx=5, pady=0))
groups[-1].grid(row=0, column=len(groups)-1,padx=5)
items = []
for item in headers[header]:
items.append(tk.Label(groups[-1],text=item))
items[-1].pack()
handles[header] = items
tk.mainloop()