Revision 964ddd88
client/python/hlrc_client/hlrc_test_gui.py | ||
---|---|---|
35 | 35 |
import sys |
36 | 36 |
import os.path |
37 | 37 |
|
38 |
from PyQt4 import QtGui, QtCore
|
|
39 |
from PyQt4.QtCore import SIGNAL
|
|
38 |
from PyQt5 import QtCore
|
|
39 |
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QSpinBox, QGroupBox, QDoubleSpinBox
|
|
40 | 40 |
|
41 |
class HLRCExample(QtGui.QWidget):
|
|
41 |
class HLRCExample(QWidget): |
|
42 | 42 |
|
43 | 43 |
def __init__(self, scope, mw): |
44 | 44 |
super(HLRCExample, self).__init__() |
... | ... | |
49 | 49 |
self.robot_controller = RobotController(self.mw, self.scope, logging.DEBUG) |
50 | 50 |
|
51 | 51 |
def initUtteranceUI(self): |
52 |
groupBox = QtGui.QGroupBox("utterances")
|
|
52 |
groupBox = QGroupBox("utterances") |
|
53 | 53 |
|
54 |
hello = QtGui.QPushButton("hello...")
|
|
54 |
hello = QPushButton("hello...") |
|
55 | 55 |
hello.clicked.connect(self.utterance_button_clicked) |
56 | 56 |
|
57 |
count = QtGui.QPushButton("12345...")
|
|
57 |
count = QPushButton("12345...") |
|
58 | 58 |
count.clicked.connect(self.utterance_button_clicked) |
59 | 59 |
|
60 | 60 |
|
61 |
vbox = QtGui.QVBoxLayout()
|
|
61 |
vbox = QVBoxLayout() |
|
62 | 62 |
vbox.addWidget(hello) |
63 | 63 |
vbox.addWidget(count) |
64 | 64 |
vbox.addStretch(1) |
... | ... | |
68 | 68 |
|
69 | 69 |
def initSpinbox(self, _min, _max, _init, double): |
70 | 70 |
if (double): |
71 |
s = QtGui.QDoubleSpinBox()
|
|
71 |
s = QDoubleSpinBox() |
|
72 | 72 |
else: |
73 |
s = QtGui.QSpinBox()
|
|
73 |
s = QSpinBox() |
|
74 | 74 |
|
75 | 75 |
s.setMinimum(_min) |
76 | 76 |
s.setMaximum(_max) |
... | ... | |
78 | 78 |
return s |
79 | 79 |
|
80 | 80 |
def initPushButton(self, base_layout, text, action): |
81 |
button = QtGui.QPushButton(text)
|
|
81 |
button = QPushButton(text) |
|
82 | 82 |
button.clicked.connect(action) |
83 | 83 |
base_layout.addWidget(button) |
84 | 84 |
|
85 | 85 |
def initEmotionUI(self): |
86 |
vbox = QtGui.QVBoxLayout()
|
|
86 |
vbox = QVBoxLayout() |
|
87 | 87 |
self.duration_spinbox = self.initSpinbox(100, 10000, 1000, 0) |
88 | 88 |
vbox.addWidget(self.duration_spinbox) |
89 | 89 |
|
... | ... | |
96 | 96 |
self.initPushButton(vbox, "fear", self.emotion_button_clicked) |
97 | 97 |
vbox.addStretch(1) |
98 | 98 |
|
99 |
groupBox = QtGui.QGroupBox("emotion")
|
|
99 |
groupBox = QGroupBox("emotion") |
|
100 | 100 |
groupBox.setLayout(vbox) |
101 | 101 |
return groupBox |
102 | 102 |
|
103 | 103 |
def initAnimationButton(self, base_layout, name): |
104 |
b = QtGui.QPushButton(name)
|
|
104 |
b = QPushButton(name) |
|
105 | 105 |
b.clicked.connect(self.animation_button_clicked) |
106 | 106 |
base_layout.addWidget(b) |
107 | 107 |
|
108 | 108 |
def initAnimUI(self): |
109 |
groupBox = QtGui.QGroupBox("animations")
|
|
109 |
groupBox = QGroupBox("animations") |
|
110 | 110 |
|
111 | 111 |
#options |
112 |
options = QtGui.QHBoxLayout()
|
|
113 |
vbox_r = QtGui.QVBoxLayout()
|
|
114 |
vbox_r.addWidget(QtGui.QLabel("repetitions"))
|
|
112 |
options = QHBoxLayout() |
|
113 |
vbox_r = QVBoxLayout() |
|
114 |
vbox_r.addWidget(QLabel("repetitions")) |
|
115 | 115 |
self.repetitions_spinbox = self.initSpinbox(1,10,1,0) |
116 | 116 |
vbox_r.addWidget(self.repetitions_spinbox) |
117 | 117 |
|
118 |
vbox_d = QtGui.QVBoxLayout()
|
|
119 |
vbox_d.addWidget(QtGui.QLabel("duration/ms (each)"))
|
|
118 |
vbox_d = QVBoxLayout() |
|
119 |
vbox_d.addWidget(QLabel("duration/ms (each)")) |
|
120 | 120 |
self.duration_each_spinbox = self.initSpinbox(50,10000,1000,0) |
121 | 121 |
vbox_d.addWidget(self.duration_each_spinbox) |
122 | 122 |
|
123 |
vbox_s = QtGui.QVBoxLayout()
|
|
124 |
vbox_s.addWidget(QtGui.QLabel("scale"))
|
|
123 |
vbox_s = QVBoxLayout() |
|
124 |
vbox_s.addWidget(QLabel("scale")) |
|
125 | 125 |
self.scale_spinbox = self.initSpinbox(0.1, 5.0, 1.0, 1) |
126 | 126 |
vbox_s.addWidget(self.scale_spinbox) |
127 | 127 |
|
... | ... | |
131 | 131 |
options.addLayout(vbox_s) |
132 | 132 |
|
133 | 133 |
#buttons |
134 |
vbox = QtGui.QVBoxLayout()
|
|
134 |
vbox = QVBoxLayout() |
|
135 | 135 |
vbox.addLayout(options) |
136 | 136 |
self.initAnimationButton(vbox, "head shake") |
137 | 137 |
self.initAnimationButton(vbox, "head nod") |
... | ... | |
146 | 146 |
return groupBox |
147 | 147 |
|
148 | 148 |
def initUI(self): |
149 |
vbox = QtGui.QVBoxLayout()
|
|
149 |
vbox = QVBoxLayout() |
|
150 | 150 |
|
151 |
hboxl = QtGui.QHBoxLayout()
|
|
152 |
hboxl.addWidget(QtGui.QLabel("base scope: "))
|
|
153 |
hboxl.addWidget(QtGui.QLabel(self.scope))
|
|
151 |
hboxl = QHBoxLayout() |
|
152 |
hboxl.addWidget(QLabel("base scope: ")) |
|
153 |
hboxl.addWidget(QLabel(self.scope)) |
|
154 | 154 |
vbox.addLayout(hboxl) |
155 | 155 |
|
156 |
hbox = QtGui.QHBoxLayout()
|
|
156 |
hbox = QHBoxLayout() |
|
157 | 157 |
vbox.addLayout(hbox) |
158 | 158 |
|
159 | 159 |
#emotion |
... | ... | |
245 | 245 |
scope = sys.argv[1] |
246 | 246 |
mw = sys.argv[2] |
247 | 247 |
|
248 |
app = QtGui.QApplication(sys.argv)
|
|
248 |
app = QApplication(sys.argv) |
|
249 | 249 |
ex = HLRCExample(mw, scope) |
250 | 250 |
sys.exit(app.exec_()) |
251 | 251 |
|
Also available in: Unified diff