label.xml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <class name="Label">
  2. <relationships>
  3. <association name="parent" class="A" min="1" max="1" />
  4. <inheritance class="MvKWidget" priority='0'/>
  5. <inheritance class="tk.Label" priority='1'/>
  6. </relationships>
  7. <constructor>
  8. <parameter name="constructor_parameters" type="dict" default="{}" />
  9. <super class="tk.Label">
  10. <parameter expr="constructor_parameters['parent']"/>
  11. <parameter expr="**({'text': constructor_parameters['text'], 'bg': 'white'})"/>
  12. </super>
  13. <super class="MvKWidget">
  14. </super>
  15. <body>
  16. self.pack()
  17. </body>
  18. </constructor>
  19. <destructor>
  20. <body>
  21. self.destroy()
  22. </body>
  23. </destructor>
  24. <method name="set_text">
  25. <parameter name="text" type="str" />
  26. <body>
  27. self.config(text=text)
  28. </body>
  29. </method>
  30. <scxml initial="root">
  31. <state id="root">
  32. <state id="running">
  33. <transition port='input' event="left-click" target='.' cond='tagorid == id(self)'>
  34. <parameter name='tagorid' type='int' default='None' />
  35. <raise event="label_pressed" scope="narrow" target="'parent'">
  36. <parameter expr="self.cget('text')" />
  37. </raise>
  38. <script>
  39. print("Left clicked label!")
  40. </script>
  41. </transition>
  42. <transition event="highlight" target=".">
  43. <script>
  44. self.config(bg="yellow")
  45. </script>
  46. </transition>
  47. <transition event="unhighlight" target=".">
  48. <script>
  49. self.config(bg="white")
  50. </script>
  51. </transition>
  52. </state>
  53. </state>
  54. </scxml>
  55. </class>