button.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <class name="Button">
  2. <relationships>
  3. <association name="parent" class="A"/>
  4. <inheritance class="MvKWidget" priority='0'/>
  5. <inheritance class="tk.Button" priority='1'/>
  6. </relationships>
  7. <constructor>
  8. <parameter name="constructor_parameters" type='dict' default='{}' />
  9. <super class="tk.Button">
  10. <parameter expr="constructor_parameters['parent']"/>
  11. <parameter expr="**(constructor_parameters['visual'].get_params())"/>
  12. </super>
  13. <super class="MvKWidget">
  14. </super>
  15. <body>
  16. self.event_parameters = constructor_parameters["event_parameters"]
  17. if "tooltip_text" in constructor_parameters:
  18. self.tooltip = ToolTip(self, constructor_parameters["tooltip_text"])
  19. else:
  20. self.tooltip = None
  21. self.visual = constructor_parameters["visual"]
  22. self.pack(**constructor_parameters.get('packing', {}))
  23. </body>
  24. </constructor>
  25. <destructor>
  26. <body>
  27. self.destroy()
  28. </body>
  29. </destructor>
  30. <scxml initial="main">
  31. <state id="main" initial='initializing'>
  32. <state id="initializing">
  33. <transition port='input' event="left-click" target='.' cond='tagorid == id(self)'>
  34. <parameter name='tagorid' type='int' default='None' />
  35. <raise event="button_pressed" scope="narrow" target="'parent'">
  36. <parameter expr="self.event_parameters" />
  37. </raise>
  38. </transition>
  39. <transition port='input' event="enter" target='.' cond='tagorid == id(self) and self.tooltip is not None'>
  40. <parameter name='tagorid' type='int' default='None' />
  41. <script>
  42. self.tooltip.showtip()
  43. </script>
  44. </transition>
  45. <transition port='input' event="leave" target='.' cond='tagorid == id(self) and self.tooltip is not None'>
  46. <parameter name='tagorid' type='int' default='None' />
  47. <script>
  48. self.tooltip.hidetip()
  49. </script>
  50. </transition>
  51. </state>
  52. </state>
  53. </scxml>
  54. </class>