| 92 | led = None # The led indicator Widget |
| 93 | |
| 94 | def __init__(self, button_label='epics button', epics_pv_name='', toggle=False, *args, **kwargs): |
| 95 | self.color_inactive = 'darkgray' |
| 96 | self.color_active = 'rgb(0,255,0)' |
| 97 | self.button = gui.Button(button_label, width="100%", height="100%", style=style_inheritance_dict) |
| 98 | self.led = gui.Widget(width=15, height=5, style={'position':'absolute', 'left':'2px', 'top':'2px', 'background-color':self.color_inactive}) |
| 99 | self.led_status = False |
| 100 | default_style = {'position':'absolute','left':'10px','top':'10px', 'background-color':'rgb(4, 90, 188)', 'color':'white'} |
| 101 | default_style.update(kwargs.get('style',{})) |
| 102 | kwargs['style'] = default_style |
| 103 | kwargs['width'] = kwargs['style'].get('width', kwargs.get('width','100px')) |
| 104 | kwargs['height'] = kwargs['style'].get('height', kwargs.get('height','100px')) |
| 105 | super(EPICSBooleanButton, self).__init__(*args, **kwargs) |
| 106 | _style = {'position':'relative'} |
| 107 | _style.update(style_inheritance_dict) |
| 108 | self.append(gui.Container(children=[self.button, self.led], width="100%", height="100%", style=_style)) |
| 109 | self.toggle = toggle |
| 110 | self.epics_pv_name = epics_pv_name |
| 111 | self.button.onmousedown.do(self.set_bit) |
| 112 | |
| 113 | def set_bit(self, emitter, *args, **kwargs): |
| 114 | self.pressed = True |