set alarm state (currently just bold font) to items in the list that get updated while invisible

This commit is contained in:
2022-12-19 17:43:56 +01:00
parent 93a2dc93ff
commit 4d045a9b1a
2 changed files with 22 additions and 0 deletions

View File

@ -1,4 +1,5 @@
from collections import defaultdict
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QListWidget, QListWidgetItem
@ -29,6 +30,7 @@ class DictList(QListWidget):
def prependItem(self, itm):
self.insertItem(0, itm)
def get(self, index):
key = self.get_key(index)
value = self.data[key]
@ -45,4 +47,21 @@ class DictList(QListWidget):
return lst[row]
def set_alarm_by_key(self, key, state):
itm = self.findItems(key, Qt.MatchExactly)[0]
set_bold(itm, state)
def set_alarm_by_index(self, index, state):
row = index.row()
itm = self.item(row)
set_bold(itm, state)
def set_bold(itm, state):
fnt = itm.font()
fnt.setBold(state)
itm.setFont(fnt)

View File

@ -53,9 +53,12 @@ class MainWindow(QMainWindow):
if sub:
desc = self.lst.data[name]
sub.plot.setData(*desc.data)
else:
self.lst.set_alarm_by_key(name, True)
def on_select_list_item(self, index):
self.lst.set_alarm_by_index(index, False)
name, desc = self.lst.get(index)
sub = self.mdi.findSubWindow(name)
if sub: