-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaViz.py
More file actions
163 lines (116 loc) · 4.89 KB
/
Copy pathMetaViz.py
File metadata and controls
163 lines (116 loc) · 4.89 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
#!pyton
import re
import tkinter as tk
from multiprocessing import Process
from tkinter import messagebox
from tkinter.scrolledtext import ScrolledText
import tkinter.font as font
import toml
from DataMgr import CDataMgr
from FilesMgr import CFileMgr
from Plot import CPlot
from utils import GetScreenSize
class CMetaViz:
scrParams = {}
sensorsData = []
proc = Process()
def Run(self):
self.CreateGUI()
def CreateRunButton(self):
self.root1 = tk.Tk()
self.scrParams = GetScreenSize()
gW = 1/4 * self.scrParams['width']
gH = 1/8 * self.scrParams['height']
gX = 3/4 * self.scrParams['width']
gY = 0
self.root1.title("Visualize Sensors Data")
self.root1.geometry('%dx%d+%d+%d' % (gW, gH, gX, gY))
myFont = font.Font(family='Helvetica', size=20, weight=font.BOLD)
self.playImg = tk.PhotoImage(file="resources\\play-button.png")
self.replayImg = tk.PhotoImage(file="resources\\replay-button.png")
self.btn1 = tk.Button(self.root1, image=self.playImg, command=self.RunBtnCallback,
height=85, width=175, compound=tk.CENTER, bg="green", font=myFont)
self.btn2 = tk.Button(self.root1, image=self.replayImg, command=self.RerunBtnCallback,
height=85, width=175, compound=tk.CENTER, bg="#7f7f00", font=myFont)
self.btn2['state'] = 'disabled'
self.btn1.place(relx=0.3, rely=0.5, anchor=tk.CENTER)
self.btn2.place(relx=0.7, rely=0.5, anchor=tk.CENTER)
def RunBtnCallback(self):
# LoadCfg()
fm = CFileMgr()
dm = CDataMgr()
pl = CPlot()
fm.Run()
sensorsRawData = fm.GetSensorsData()
dm.SetCarpetFilePath(fm.GetCarpetFilePath())
dm.SetSensorsRawData(sensorsRawData)
dm.Run()
self.sensorsData = dm.GetSensorsData()
# pl.Run(self.sensorsData)
if self.proc.name == 'Plot':
self.proc.kill()
self.proc = Process(name='Plot', target=pl.Run,
args=(self.sensorsData,))
self.proc.start()
self.btn2['state'] = 'normal'
def RerunBtnCallback(self):
pl = CPlot()
if self.proc.name == 'Plot':
self.proc.kill()
self.proc = Process(name='Plot', target=pl.Run,
args=(self.sensorsData,))
self.proc.start()
def CreateCfgEditor(self):
self.cfg = toml.load("app_cfg.toml")
appCfgFile = open(self.cfg["cfgFilePath"], 'r')
appCfgTxt = appCfgFile.read()
appCfgFile.close()
gW = 0.25 * self.scrParams['width']
gH = 0.875 * self.scrParams['height'] - 105
gX = 0.75 * self.scrParams['width']
gY = 0.125 * self.scrParams['height'] + 32
self.root2 = tk.Tk()
self.txt = ScrolledText(self.root2, width=80, height=80, undo=True)
# self.txt.insert(tk.END, appCfgTxt)
self.root2.bind_all("<Control-s>", self.CfgEditorSave)
self.txt.bind('<Key>', self.TxtModifiedCallback)
self.txt.bind('<Control-z>', self.UndoCallback)
self.txt.tag_configure("Comment", foreground="#B27300")
self.txt.tag_configure("RegularText", foreground="#000000")
self.txt.tag_configure("Tags", foreground="#0000FF")
self.ApplySyntaxHl(appCfgTxt)
# self.txt.tag_configure("Token.Comment", foreground="#b21111")
self.root2.title("CFG Editor")
self.root2.geometry('%dx%d+%d+%d' % (gW, gH, gX, gY))
self.txt.pack()
def ApplySyntaxHl(self, appCfgTxt):
appCfgTxtLines = appCfgTxt.split('\n')
for cfgLine in appCfgTxtLines:
if re.search('^\\s*\\#', cfgLine, re.VERBOSE):
self.txt.insert("end", cfgLine, 'Comment')
elif re.search('^\\s*\\[', cfgLine, re.VERBOSE):
self.txt.insert("end", cfgLine, 'Tags')
else:
self.txt.insert("end", cfgLine, 'RegularText')
self.txt.insert("end", '\n', 'RegularText')
def TxtModifiedCallback(self, event):
# Save combination pressed:
if event.keycode != 17:
self.root2.title("CFG Editor*")
def UndoCallback(self, *args):
self.ApplySyntaxHl(self.txt.get("1.0", "end"))
def CfgEditorSave(self, *args):
txt = self.txt.get("1.0", "end")
filename = self.cfg["cfgFilePath"]
with open(filename, 'w') as f:
f.write(txt)
f.close()
self.root2.title("CFG Editor")
# messagebox.showinfo("Save", "CFG file saved...")
def CreateGUI(self):
self.CreateRunButton()
self.CreateCfgEditor()
self.root1.mainloop()
if __name__ == "__main__":
sdv = CMetaViz()
sdv.Run()