set alarm state (currently just bold font) to items in the list that get updated while invisible
This commit is contained in:
@ -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)
|
||||
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user