Base class for graphical gui widgets. A widget has a graphical css style and receives events from the webpage
| 510 | |
| 511 | |
| 512 | class Widget(Tag, EventSource): |
| 513 | """ Base class for graphical gui widgets. |
| 514 | A widget has a graphical css style and receives events from the webpage |
| 515 | """ |
| 516 | # some constants for the events |
| 517 | EVENT_ONCLICK = 'onclick' |
| 518 | EVENT_ONDBLCLICK = 'ondblclick' |
| 519 | EVENT_ONMOUSEDOWN = 'onmousedown' |
| 520 | EVENT_ONMOUSEMOVE = 'onmousemove' |
| 521 | EVENT_ONMOUSEOVER = 'onmouseover' |
| 522 | EVENT_ONMOUSEOUT = 'onmouseout' |
| 523 | EVENT_ONMOUSELEAVE = 'onmouseleave' |
| 524 | EVENT_ONMOUSEUP = 'onmouseup' |
| 525 | EVENT_ONTOUCHMOVE = 'ontouchmove' |
| 526 | EVENT_ONTOUCHSTART = 'ontouchstart' |
| 527 | EVENT_ONTOUCHEND = 'ontouchend' |
| 528 | EVENT_ONTOUCHENTER = 'ontouchenter' |
| 529 | EVENT_ONTOUCHLEAVE = 'ontouchleave' |
| 530 | EVENT_ONTOUCHCANCEL = 'ontouchcancel' |
| 531 | EVENT_ONKEYDOWN = 'onkeydown' |
| 532 | EVENT_ONKEYPRESS = 'onkeypress' |
| 533 | EVENT_ONKEYUP = 'onkeyup' |
| 534 | EVENT_ONCHANGE = 'onchange' |
| 535 | EVENT_ONINPUT = 'oninput' |
| 536 | EVENT_ONFOCUS = 'onfocus' |
| 537 | EVENT_ONBLUR = 'onblur' |
| 538 | EVENT_ONCONTEXTMENU = "oncontextmenu" |
| 539 | EVENT_ONUPDATE = 'onupdate' |
| 540 | |
| 541 | # None is not visible in editor |
| 542 | @property |
| 543 | @editor_attribute_decorator("Generic", '''The variable name used by the editor''', str, {}) |
| 544 | def variable_name(self): return self.__dict__.get('__variable_name', None) |
| 545 | @variable_name.setter |
| 546 | def variable_name(self, value): self.__dict__['__variable_name'] = value |
| 547 | @variable_name.deleter |
| 548 | def variable_name(self): del self.__dict__['__variable_name'] |
| 549 | |
| 550 | @property |
| 551 | @editor_attribute_decorator("Generic",'''The html class attribute, allows to assign a css style class. Multiple classes have to be separed by space.''', str, {}) |
| 552 | def attr_class(self): return self.attributes.get('class', None) |
| 553 | @attr_class.setter |
| 554 | def attr_class(self, value): self.attributes['class'] = value |
| 555 | @attr_class.deleter |
| 556 | def attr_class(self): del self.attributes['class'] |
| 557 | |
| 558 | @property |
| 559 | @editor_attribute_decorator("Generic",'''Defines if to overload the base class''', bool, {}) |
| 560 | def attr_editor_newclass(self): return self.__dict__.get('__editor_newclass', False) |
| 561 | @attr_editor_newclass.setter |
| 562 | def attr_editor_newclass(self, value): self.__dict__['__editor_newclass'] = value |
| 563 | @attr_editor_newclass.deleter |
| 564 | def attr_editor_newclass(self): del self.__dict__['__editor_newclass'] |
| 565 | |
| 566 | @property |
| 567 | @editor_attribute_decorator("Layout", '''CSS float.''', 'DropDown', {'possible_values': ('none', 'inherit ', 'left', 'right')}) |
| 568 | def css_float(self): return self.style.get('float', None) |
| 569 | @css_float.setter |