-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdisplay_text_node.py
62 lines (43 loc) · 1.73 KB
/
display_text_node.py
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
import pyqtgraph.flowchart.library as fclib
from pyqtgraph.Qt import QtWidgets
from pyqtgraph.flowchart import Node
from node_constants import NodeKey
"""
DisplayTextNode that displays the latest predicted category (the given text) on the screen.
DisplayTextWidget is responsible for the UI of the DisplayTextNode / for setting the text.
"""
# Author: Claudia
# Reviewer: Martina
class DisplayTextNode(Node):
nodeName = "DisplayText"
@staticmethod
def get_node_name():
return DisplayTextNode.nodeName
def __init__(self, name):
terminals = {
NodeKey.TEXT.value: dict(io="in")
}
self.__display_text_widget = DisplayTextWidget()
Node.__init__(self, name, terminals=terminals)
def process(self, **kwargs):
text = kwargs[NodeKey.TEXT.value]
self.__display_text_widget.set_predicted_category_text(text)
def ctrlWidget(self):
return self.__display_text_widget
fclib.registerNodeType(DisplayTextNode, [(DisplayTextNode.get_node_name(),)])
class DisplayTextWidget(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.__setup_layout()
def __setup_layout(self):
layout = QtWidgets.QVBoxLayout()
self.__category_info = QtWidgets.QLabel()
self.__category_info.setText("predicted gesture:")
layout.addWidget(self.__category_info)
self.__predicted_category = QtWidgets.QLabel()
self.__predicted_category.setText("invalid state")
self.__predicted_category.setWordWrap(True)
layout.addWidget(self.__predicted_category)
self.setLayout(layout)
def set_predicted_category_text(self, predicted_category):
self.__predicted_category.setText(predicted_category)