OlliTut/GUI/status_bar.py

43 lines
1.5 KiB
Python

import wx
class StatusPanel(wx.Panel):
def __init__(self, parent, pd):
super().__init__(parent, -1)
#TODO get proper data
data = {"over1":False,"over2":True,"motor":123}
sizer_status = wx.GridBagSizer(vgap=5, hgap=5)
self.status={}
self.green = wx.Bitmap("./GUI/img/green.bmp")
self.red = wx.Bitmap("./GUI/img/red.bmp")
row = 0
for key, val in data.items():
label = wx.StaticText(self, wx.ID_ANY, key)
sizer_status.Add(label, (row,0))
if type(val) is bool:
if val:
icon = wx.StaticBitmap(self,bitmap=self.green)
self.status[key] = icon
sizer_status.Add(icon, (row,1))
else:
icon = wx.StaticBitmap(self,bitmap=self.red)
self.status[key] = icon
sizer_status.Add(icon, (row,1))
else:
label = wx.StaticText(self, wx.ID_ANY, str(val))
self.status[key] = label
sizer_status.Add(label, (row,1))
row +=1
def update(self):
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))