Skip to content

Commit 5217cea

Browse files
committed
implement tooltip in client defined as description field in yaml files
1 parent 3f471f7 commit 5217cea

10 files changed

Lines changed: 47 additions & 11 deletions

File tree

rcm/client/gui/new_display_dialog.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def recursive_init_ui(self, d, parent_widget, parent_layout, path="", var=""):
135135
values = d.get('values', None)
136136
label = d.get('label', None)
137137
widget_type = d.get('type', None)
138+
description = d.get('description', None)
138139

139140
if values:
140141
gui_widget = create_hor_composite_widget(parent_widget,
@@ -143,7 +144,8 @@ def recursive_init_ui(self, d, parent_widget, parent_layout, path="", var=""):
143144
widget_type,
144145
values,
145146
path,
146-
var)
147+
var,
148+
description )
147149
gui_widget.parent = self
148150
gui_widget.update()
149151
parent_widget.widgets.append(gui_widget)
@@ -207,7 +209,8 @@ def create_hor_composite_widget(parent_widget,
207209
widget_type=None,
208210
parameters=None,
209211
path='',
210-
var=''):
212+
var='',
213+
description=''):
211214
"""
212215
Create a horizontal composite widget to be added in the main vertical layout
213216
The composite widget is made of a qlabel + an interactive gui widget
@@ -228,7 +231,7 @@ def create_hor_composite_widget(parent_widget,
228231
label_widget = QLabel("%s:" % label)
229232
hor_layout.addWidget(label_widget)
230233

231-
qvar_widget = widget_factory(widget_type)(parameters, path, var, parent_widget)
234+
qvar_widget = widget_factory(widget_type)(parameters, path, var, parent_widget, description)
232235

233236
hor_layout.addWidget(qvar_widget)
234237
main_widget.setLayout(hor_layout)
@@ -263,7 +266,7 @@ def widget_factory(widget_type):
263266

264267
# nested class
265268
class ComboBox(QComboBox):
266-
def __init__(self, values=None, path='', var='', parent_widget=None):
269+
def __init__(self, values=None, path='', var='', parent_widget=None, description=None):
267270
QComboBox.__init__(self)
268271
self.parent_widget = parent_widget
269272
self.var = var
@@ -272,7 +275,15 @@ def __init__(self, values=None, path='', var='', parent_widget=None):
272275
self.path = path
273276
self.currentIndexChanged.connect(lambda: self.combo_box_change(self.choices))
274277
self.addItems(values)
278+
count = 0
279+
for v in values:
280+
choice_description = values[v].get('description','')
281+
if choice_description:
282+
self.setItemData(count, choice_description, Qt.ToolTipRole)
283+
count += 1
275284
self.setCurrentIndex(0)
285+
if description:
286+
self.setToolTip(description)
276287

277288
def update(self):
278289
self.currentIndexChanged.emit(0)
@@ -301,7 +312,7 @@ def combo_box_change(self, values):
301312
hide_childs(self.parent.containers[new_key])
302313

303314
class Divider(QFrame):
304-
def __init__(self, values=None, path='', var='', parent_widget=None):
315+
def __init__(self, values=None, path='', var='', parent_widget=None, description=None):
305316
QFrame.__init__(self)
306317
self.setFrameShape(QFrame.HLine)
307318
self.setFrameShadow(QFrame.Sunken)
@@ -312,7 +323,7 @@ def update(self):
312323
return
313324

314325
class Slider(QWidget):
315-
def __init__(self, values=None, path='', var='', parent_widget=None):
326+
def __init__(self, values=None, path='', var='', parent_widget=None, description=None):
316327
QWidget.__init__(self)
317328
self.parent = None
318329
self.var = var
@@ -329,6 +340,11 @@ def __init__(self, values=None, path='', var='', parent_widget=None):
329340
self.slider.setFixedWidth(100)
330341
self.slider.setMinimum(values.get('min'))
331342
self.slider.setMaximum(values.get('max'))
343+
if 'description' in values:
344+
self.slider.setToolTip(values['description'])
345+
else:
346+
if description:
347+
self.slider.setToolTip(description)
332348

333349
self.slider_edit.textChanged.connect(self.slider_edit_change)
334350
self.slider.valueChanged.connect(self.slider_change)

rcm/server/etc/defaults/schema_00_top.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ schema:
2323
SCHEDULER:
2424
label : 'Scheduler'
2525
type : 'combobox'
26+
description : "Select the scheduler for starting the service"
27+
2628

2729

2830
DIVIDER:
@@ -33,6 +35,8 @@ schema:
3335
SERVICE :
3436
label : 'Service Type'
3537
type: 'combobox'
38+
description : "Select the service type to start"
39+
3640
substitutions :
3741
COMMAND.SETUP: ""
3842
COMMAND.COMMAND_LINE: ""

rcm/server/etc/defaults/schema_02_service.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ schema:
1717
COMMAND :
1818
label : 'Command'
1919
type : 'combobox'
20-
20+
description : "Select the specific command to start the service"
2121
substitutions :
2222
# COMMAND: "vncserver @{WM_FLAGS} $vnc_foreground -geometry @{DISPLAY} -rfbauth $RCM_JOBLOG.pwd @{WM_COMMAND "
2323
COMMAND_LINE: ""
@@ -28,6 +28,7 @@ schema:
2828
WM :
2929
label : 'Window Manager'
3030
type : 'combobox'
31+
description : "Select the window manager"
3132
substitutions :
3233
WM_COMMAND: ""
3334
WM_FLAGS: ""
@@ -36,12 +37,14 @@ schema:
3637
XSIZE :
3738
label : 'X size'
3839
type : 'slider'
40+
description : "Horizontal dimension of VNC Display window"
3941
values :
4042
min : 300
4143
max : 3000
4244
YSIZE :
4345
label : 'Y size'
4446
type : 'slider'
47+
description : "Vertical dimension of VNC Display window"
4548
values :
4649
min : 300
4750
max : 3000

rcm/server/lib/jobscript_builder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@ def get_gui_options(self):
260260
options[child.NAME] = child.get_gui_options()
261261

262262
if options:
263-
return {'children': options}
263+
result = {'children': options}
264264
else:
265-
return options
265+
result = options
266+
if 'description' in self.defaults:
267+
result['description'] = self.defaults['description']
268+
return result
269+
266270

267271

268272
class ManagerChoiceNode(ChoiceNode):

rcm/server/test/etc/test_hierarchical/base_scheduler/slurm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defaults:
22
TOP:
33
SCHEDULER :
44
Slurm :
5-
5+
description : "Start service using Slurm batch scheduler"
66
substitutions :
77
# WARNING: on regex, \ must be escaped
88
JOBID_REGEX: "Submitted batch job (\\d*)"

rcm/server/test/etc/test_hierarchical/base_scheduler/ssh.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defaults:
22
TOP:
33
SCHEDULER :
44
SSH :
5-
5+
description : "Start service using a process on the login node"
66
substitutions :
77
# WARNING: on regex, \ and " must be escaped
88
JOBID_REGEX: "process id: (\\d*)"

rcm/server/test/etc/test_hierarchical/base_service/turbovnc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ defaults:
22
TOP:
33
SERVICE :
44
VNC :
5+
description : "Start service of type VNC "
56
COMMAND :
67
TurboVNC :
8+
description : "Select TurboVNC as VNC server "
79
substitutions :
810
SETUP: "module load rcm"
911
LOGFILE: "@{RCM_SESSION_FOLDER}/vnclog"
@@ -17,9 +19,11 @@ defaults:
1719

1820
WM :
1921
Fluxbox :
22+
description : "Start Fluxbox as Window manager for the VNC session (lightest choice)"
2023
substitutions :
2124
WM_COMMAND: "-xstartup ${RCM_HOME}/bin/config/xstartup.fluxbox"
2225
XSIZE:
26+
description : "Screen hor size "
2327
min : 400
2428
YSIZE:
2529
min : 400

rcm/server/test/etc/test_hierarchical/other/other_service_type.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ defaults:
22
TOP:
33
SERVICE :
44
Other :
5+
description : "Placeholder for other type of sarvice"
56
COMMAND :
67
FakeService :
78
otherstuff :
9+
description : " this is a dummy service example"
810
substitutions :
911
SETUP: "# fake module load "
1012
LOGFILE: "@{RCM_SESSION_FOLDER}/fakelog"

rcm/server/test/etc/test_hierarchical/other/other_vnc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defaults:
44
VNC :
55
COMMAND :
66
OtherVNC :
7+
description : "Placeholder for Other VNC server"
78
substitutions :
89
COMMAND_LINE: "other_vncserver "
910
DISPLAY :

rcm/server/test/etc/test_hierarchical/other/other_wm.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ defaults:
66
TurboVNC :
77
WM :
88
KDE :
9+
description : "Start KDE as Window manager for the VNC session (heavvier choice)"
910
substitutions :
1011
WM_COMMAND: "-xstartup ${RCM_HOME}/bin/config/xstartup.kde"
1112
GnomeGL :
13+
description : "Start Gnome as Window manager for the VNC session, needs OpenGL (VirtualGL support)"
1214
substitutions :
1315
WM_COMMAND: "-xstartup ${RCM_HOME}/bin/config/xstartup.gnomegl"
1416
WM_FLAGS: " -3dwm "

0 commit comments

Comments
 (0)