| 318 | led = None # The led indicator Widget |
| 319 | |
| 320 | def __init__(self, button_label='siemens button', db_index=-1, byte_index=-1, bit_index=-1, toggle=False, *args, **kwargs): |
| 321 | self.color_inactive = 'darkgray' |
| 322 | self.color_active = 'rgb(0,255,0)' |
| 323 | _style = style_inheritance_text_dict |
| 324 | _style.update(style_inheritance_dict) |
| 325 | self.button = gui.Button(button_label, width="100%", height="100%", style=_style) |
| 326 | self.led = gui.Widget(width=15, height=5, style={'position':'absolute', 'left':'2px', 'top':'2px', 'background-color':self.color_inactive}) |
| 327 | self.led_status = False |
| 328 | default_style = {'position':'absolute','left':'10px','top':'10px', 'background-color':'rgb(4, 90, 188)', 'color':'white'} |
| 329 | default_style.update(kwargs.get('style',{})) |
| 330 | kwargs['style'] = default_style |
| 331 | kwargs['width'] = kwargs['style'].get('width', kwargs.get('width','100px')) |
| 332 | kwargs['height'] = kwargs['style'].get('height', kwargs.get('height','100px')) |
| 333 | super(SiemensButton, self).__init__(*args, **kwargs) |
| 334 | SiemensWidget._setup(self) |
| 335 | _style = {'position':'relative'} |
| 336 | _style.update(style_inheritance_dict) |
| 337 | self.append(gui.Container(children=[self.button, self.led], width="100%", height="100%", style=_style)) |
| 338 | self.toggle = toggle |
| 339 | self.button.onmousedown.do(self.set_bit) |
| 340 | self.button.onmouseup.do(self.reset_bit) |
| 341 | |
| 342 | def set_bit(self, emitter, *args, **kwargs): |
| 343 | if self.db_index<0 or self.byte_index<0 or self.bit_index<0: |