def renderParam(param, func, title, val, circle=None): i = None if param.type == 'slider': if isinstance(param.opts, dict): i = interactive(func, val=(param.opts['low'], param.opts['high'], param.opts['step'])) else: s = interactive(func, val=(0, len(param.opts) - 1, 1)) s.children[0].readout = False l = Label(value=str(param.opts[0]), layout=Layout(margin='0 0 0 15px')) i = HBox([s.children[0], l]) elif param.type == 'check': i = interactive(func, val=val) elif param.type == 'menu': i = interactive(func, val=[(k[1], k[0]) for k in param.opts.items()]) elif param.type == 'checkentry': defaults = ( (isinstance(val, param.entryType) or val) if not (param.name == 'stopafter' and param.event) else True, #Bool (str(val) if isinstance(val, param.entryType) else '') if not (param.name == 'stopafter' and param.event) else 'Event: ' + val #Str ) i = interactive(func, b=defaults[0], s=defaults[1]) if param.obj is None: i = HBox(i.children) i.children[0].layout = Layout(width='150px') if val == False: i.children[1].disabled = True i.children[1].description = '' if param.name == 'stopafter' and param.event: i.children[0].disabled = True i.children[1].disabled = True i.add_class('helipad_checkentry_func') elif param.type == 'checkgrid': param.element = {} for k, v in param.opts.items(): if not isinstance(v, (tuple, list)): v = (v, None) elif len(v) < 2: v = (v[0], None) param.element[k] = interactive(param.setVar(k), val=param.vars[k]) param.element[k].children[0].description = v[0] param.element[k].children[ 0].description_tooltip = v[1] if v[ 1] is not None else '' #Not working, not sure why param.containerElement = HBox(list(param.element.values())) i = Accordion(children=[param.containerElement]) i.set_title(0, title) i.add_class('helipad_checkgrid') if i is not None and param.type != 'checkgrid': circle = '<span class="helipad_circle" style="background:' + circle.hex + '"></span>' if circle is not None else '' i.children[0].description = circle + title i.children[0].style = { 'description_width': 'initial' } #Don't truncate the label i.children[ 0].description_tooltip = param.desc if param.desc is not None else '' if param.type == 'slider' and isinstance(param.opts, list): i.children[1].value = str(val) if val in param.opts: val = param.opts.index(val) if param.type != 'checkentry': i.children[0].value = val return i