Added display for Status Information

This commit is contained in:
Jacob Holder 2021-10-02 17:34:07 +02:00
parent 31046f0a87
commit a677868634
Signed by: jacob
GPG Key ID: 2194FC747048A7FD
4 changed files with 37 additions and 12 deletions

BIN
img/green.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/red.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -20,8 +20,7 @@ from matplotlib.backends.backend_wxagg import (
from matplotlib.figure import Figure
import logging
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger()
LOGGER = logging.getLogger("mylogger")
class PlotPanel(wx.Panel):

46
view.py
View File

@ -24,8 +24,7 @@ from matplotlib.backends.backend_wxagg import (
from matplotlib.figure import Figure
from plotView import PlotPanel
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger()
LOGGER = logging.getLogger("myLogger")
# begin wxGlade: dependencies
# end wxGlade
@ -71,21 +70,36 @@ class MyFrame(wx.Frame):
grid_sizer_main = wx.GridBagSizer(0, 0)
sizer_status = wx.BoxSizer(wx.VERTICAL)
sizer_status = wx.GridBagSizer(vgap=5, hgap=5)
grid_sizer_main.Add(sizer_status, (0, 0), (2, 1), wx.EXPAND, 0)
# TODO test
label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "Text1")
sizer_status.Add(label_1, 0, 0, 0)
label_2 = wx.StaticText(self.panel_1, wx.ID_ANY, u"Für")
sizer_status.Add(label_2, 0, 0, 0)
label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, "Statis")
sizer_status.Add(label_3, 0, 0, 0)
data = {"over1":False,"over2":True,"motor":123}
self.status={}
self.green = wx.Bitmap("./img/green.bmp")
self.red = wx.Bitmap("./img/red.bmp")
row = 0
for key, val in data.items():
label = wx.StaticText(self.panel_1, wx.ID_ANY, key)
sizer_status.Add(label, (row,0))
if type(val) is bool:
if val:
icon = wx.StaticBitmap(self.panel_1,bitmap=self.green)
self.status[key] = icon
sizer_status.Add(icon, (row,1))
else:
icon = wx.StaticBitmap(self.panel_1,bitmap=self.red)
self.status[key] = icon
sizer_status.Add(icon, (row,1))
else:
label = wx.StaticText(self.panel_1, wx.ID_ANY, str(val))
self.status[key] = label
sizer_status.Add(label, (row,1))
row +=1
self.tabs = wx.Notebook(self.panel_1, wx.ID_ANY)
grid_sizer_main.Add(self.tabs, (0, 1), (1, 1), wx.EXPAND, 0)
plot = lambda ax, dat: ax.plot(dat["time"], dat["temp"])
update = lambda im, dat: im.set_data(dat["time"], dat["temp"])
self.plot_1 = PlotPanel(self.tabs, self.model, plot, update)
@ -155,11 +169,23 @@ class MyFrame(wx.Frame):
wx.Exit()
def update(self, event):
#Repaint gui
self.tabs.Refresh()
#Unlock if script is finished
if self.runner_thread is not None:
if not self.runner_thread.is_alive():
self.unlock()
self.runner_thread = None
#update Stuff
data = {"over1":True,"over2":True,"motor":12}
for key,val in data.items():
if type(val) is bool:
if val:
self.status[key].SetBitmap(self.green)
else:
self.status[key].SetBitmap(self.red)
else:
self.status[key].SetLabel(str(val))
def lock(self):
self.b_run.Disable()