Skip to content

Commit 14dcaad

Browse files
committed
Merge branch 'dev'
2 parents cc6e7ab + 6dc2b60 commit 14dcaad

13 files changed

+306
-68
lines changed

config/gui_settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
event_history_len = 200 # Length of event history to plot (# events).
88
state_history_len = 100 # Length of state history to plot (# states).
99
analog_history_dur = 12 # Duration of analog signal history to plot (seconds).
10+
active_cerebros = ["1","23"]
1011

1112
ui_font_size = 11 # Font size of UI elements (button text, label text etc.).
1213
log_font_size = 9 # Font size of the data log.

config/user_variable_dialogs/blinker_gui.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"green_count": {
2222
"label": "\ud83d\udfe2Green count",
2323
"widget": "spinbox",
24-
"min": 0,
24+
"min": 1,
2525
"max": 10,
2626
"step": 1,
2727
"suffix": "blinks",
@@ -39,7 +39,7 @@
3939
"red_count": {
4040
"label": "\ud83d\udd34Red count",
4141
"widget": "spinbox",
42-
"min": 0,
42+
"min": 1,
4343
"max": 10,
4444
"step": 1,
4545
"suffix": "blinks",
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# This is an example custom dialog for more advanced users.
2+
# Complex custom dialogs can be directly coded using the PyQt framework
3+
4+
from pyqtgraph.Qt import QtGui, QtCore
5+
from gui.custom_variables_dialog import Slider_var, Spin_var
6+
7+
# Custom Variable dialog
8+
class Custom_variables_dialog(QtGui.QDialog):
9+
# Dialog for setting and getting task variables.
10+
def __init__(self, parent, board):
11+
super(QtGui.QDialog, self).__init__(parent)
12+
self.setWindowTitle("Blink Variable GUI")
13+
self.layout = QtGui.QVBoxLayout(self)
14+
self.variables_grid = Variables_grid(self, board)
15+
self.layout.addWidget(self.variables_grid)
16+
self.layout.setContentsMargins(0, 0, 0, 0)
17+
self.setLayout(self.layout)
18+
19+
20+
class Variables_grid(QtGui.QWidget):
21+
def __init__(self, parent, board):
22+
super(QtGui.QWidget, self).__init__(parent)
23+
variables = board.sm_info["variables"]
24+
self.grid_layout = QtGui.QGridLayout()
25+
initial_variables_dict = {v_name: v_value_str for (v_name, v_value_str) in sorted(variables.items())}
26+
self.variables_gui = Variables_gui(self, self.grid_layout, board, initial_variables_dict)
27+
self.setLayout(self.grid_layout)
28+
29+
30+
class Variables_gui(QtGui.QWidget):
31+
def __init__(self, parent, grid_layout, board, init_vars):
32+
super(QtGui.QWidget, self).__init__(parent)
33+
self.board = board
34+
35+
# create widgets
36+
widget = QtGui.QWidget()
37+
layout = QtGui.QGridLayout()
38+
row = 0
39+
40+
# blink rate controls
41+
self.blink_rate = Slider_var(init_vars, "⏱️ <b>Blink Rate</b>", 1, 15, 0.5, "blink_rate")
42+
self.blink_rate.setSuffix(" Hz")
43+
self.blink_rate.setHint("Frequency of alternating LED blinks")
44+
self.blink_rate.setBoard(board)
45+
self.blink_rate.add_to_grid(layout, row)
46+
row += 1
47+
self.min_btn = QtGui.QPushButton("min")
48+
self.mid_btn = QtGui.QPushButton("50%")
49+
self.max_btn = QtGui.QPushButton("max")
50+
for col,btn in enumerate([self.min_btn,self.mid_btn,self.max_btn]):
51+
layout.addWidget(btn, row,col, QtCore.Qt.AlignCenter)
52+
btn.setFocusPolicy(QtCore.Qt.NoFocus)
53+
btn.setMaximumWidth(70)
54+
row += 1
55+
56+
# separator
57+
layout.addWidget(QtGui.QLabel("<hr>"), row, 0, 1, 4)
58+
row += 1
59+
60+
# radio buttons
61+
red_is_enabled = eval(init_vars["red_enabled"])
62+
green_is_enabled = eval(init_vars["green_enabled"])
63+
self.both_radio = QtGui.QRadioButton()
64+
self.both_lbl = QtGui.QLabel("🔴Both🟢")
65+
self.red_radio = QtGui.QRadioButton()
66+
self.red_lbl = QtGui.QLabel("Red")
67+
self.red_lbl.setStyleSheet("border:3px solid red;background:red;border-radius:3px;") # you can use css styling
68+
self.green_radio = QtGui.QRadioButton()
69+
self.green_lbl = QtGui.QLabel("Green")
70+
self.green_lbl.setStyleSheet("border-radius:3px;border:3px solid green;background:green;color:white")
71+
if red_is_enabled and green_is_enabled:
72+
self.both_radio.setChecked(True)
73+
self.red_radio.setChecked(False)
74+
self.green_radio.setChecked(False)
75+
else:
76+
self.both_radio.setChecked(False)
77+
if red_is_enabled:
78+
self.red_radio.setChecked(True)
79+
self.green_radio.setChecked(False)
80+
elif green_is_enabled:
81+
self.red_radio.setChecked(False)
82+
self.green_radio.setChecked(True)
83+
else:
84+
self.red_radio.setChecked(False)
85+
self.green_radio.setChecked(False)
86+
87+
layout.addWidget(self.both_lbl, row, 0, QtCore.Qt.AlignCenter)
88+
layout.addWidget(self.red_lbl, row, 1, QtCore.Qt.AlignCenter)
89+
layout.addWidget(self.green_lbl, row, 2, QtCore.Qt.AlignCenter)
90+
row += 1
91+
layout.addWidget(self.both_radio, row, 0, QtCore.Qt.AlignCenter)
92+
layout.addWidget(self.red_radio, row, 1, QtCore.Qt.AlignCenter)
93+
layout.addWidget(self.green_radio, row, 2, QtCore.Qt.AlignCenter)
94+
row += 1
95+
96+
# counts
97+
self.red_count = Spin_var(init_vars, "<b>Red count</b>", 1, 10, 1, "red_count")
98+
self.red_count.setBoard(board)
99+
self.red_count.add_to_grid(layout, row)
100+
row += 1
101+
self.green_count = Spin_var(init_vars, "<b>Green count</b>", 1, 10, 1, "green_count")
102+
self.green_count.setBoard(board)
103+
self.green_count.add_to_grid(layout, row)
104+
row += 1
105+
106+
# image
107+
self.picture = QtGui.QLabel()
108+
image = QtGui.QPixmap("config/user_variable_dialogs/example_image.png")
109+
self.picture.setPixmap(image)
110+
layout.addWidget(self.picture, row, 0, 1, 4)
111+
row += 1
112+
113+
# gif
114+
self.gif = QtGui.QLabel()
115+
self.movie = QtGui.QMovie("config/user_variable_dialogs/example_movie.gif")
116+
self.gif.setMovie(self.movie)
117+
self.movie.start()
118+
layout.addWidget(self.gif, row, 0, 1, 4)
119+
row += 1
120+
121+
layout.setRowStretch(row, 1)
122+
widget.setLayout(layout)
123+
grid_layout.addWidget(widget, 0, 0, QtCore.Qt.AlignLeft)
124+
125+
# connect some buttons to functions
126+
self.min_btn.clicked.connect(self.slide_to_min)
127+
self.mid_btn.clicked.connect(self.slide_to_mid)
128+
self.max_btn.clicked.connect(self.slide_to_max)
129+
self.both_radio.clicked.connect(self.update_count_options)
130+
self.red_radio.clicked.connect(self.update_count_options)
131+
self.green_radio.clicked.connect(self.update_count_options)
132+
133+
# add close shortcut
134+
self.close_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+W"), self)
135+
self.close_shortcut.activated.connect(self.close)
136+
137+
def update_count_options(self):
138+
red_val = self.red_radio.isChecked() | self.both_radio.isChecked()
139+
green_val = self.green_radio.isChecked() | self.both_radio.isChecked()
140+
self.board.set_variable("red_enabled", red_val) # update variable
141+
self.board.set_variable("green_enabled", green_val)
142+
self.red_count.setEnabled(red_val) # enable or disable control
143+
self.green_count.setEnabled(green_val)
144+
if not self.board.framework_running: # Value returned later.
145+
msg = QtGui.QMessageBox()
146+
msg.setText("Variable Changed")
147+
msg.exec()
148+
149+
def slide_to_min(self):
150+
self.blink_rate.slider.setValue(1)
151+
self.blink_rate.update_val_lbl()
152+
self.blink_rate.set()
153+
154+
def slide_to_mid(self):
155+
self.blink_rate.slider.setValue(7.5)
156+
self.blink_rate.update_val_lbl()
157+
self.blink_rate.set()
158+
159+
def slide_to_max(self):
160+
self.blink_rate.slider.setValue(15)
161+
self.blink_rate.update_val_lbl()
162+
self.blink_rate.set()

config/user_variable_dialogs/blinker_gui_tabs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"green_count": {
1313
"label": "count",
1414
"widget": "spinbox",
15-
"min": 0,
15+
"min": 1,
1616
"max": 10,
1717
"step": 1,
1818
"suffix": "blinks",
Loading
1.42 MB
Loading

gui/configure_experiment_tab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def add_subject(self, setup=None, subject=None, do_run=None):
393393
remove_button.setIcon(QtGui.QIcon("gui/icons/remove.svg"))
394394
ind = QtCore.QPersistentModelIndex(self.model().index(self.n_subjects, 2))
395395
remove_button.clicked.connect(lambda :self.remove_subject(ind.row()))
396-
add_button = QtGui.QPushButton('add')
396+
add_button = QtGui.QPushButton(' add ')
397397
add_button.setIcon(QtGui.QIcon("gui/icons/add.svg"))
398398
add_button.clicked.connect(self.add_subject)
399399
run_checkbox = TableCheckbox()

0 commit comments

Comments
 (0)