dsl_toolbar.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <class name="DSLToolbar">
  2. <relationships>
  3. <inheritance class="Toolbar"/>
  4. <association name="buttons" class="Button"/>
  5. <association name="parent" class="A"/>
  6. </relationships>
  7. <constructor>
  8. <parameter name="parent"/>
  9. <super class="Toolbar">
  10. <parameter expr="parent"/>
  11. </super>
  12. <body>
  13. self.to_create = ["new"]
  14. self.button_info = {"new": "REMOVE"}
  15. self.buttons = {}
  16. </body>
  17. </constructor>
  18. <destructor>
  19. <super class="Toolbar"/>
  20. </destructor>
  21. <scxml initial="init">
  22. <state id="init" initial="init_buttons">
  23. <onexit>
  24. <raise event="tk_widget" scope="narrow" target="'parent'">
  25. <parameter expr="self"/>
  26. </raise>
  27. </onexit>
  28. <state id="init_buttons">
  29. <onentry>
  30. <raise event="create_instance" scope="cd">
  31. <parameter expr="'buttons'"/>
  32. <parameter expr="'Button'"/>
  33. <parameter expr="{'parent': self, 'visual': ImageVisual('icons/%s.png' % self.to_create[0]), 'tooltip_text': self.button_info[self.to_create[0]], 'event_parameters': self.to_create[0]}"/>
  34. </raise>
  35. </onentry>
  36. <transition event="instance_created" target="../pack_button">
  37. <parameter name="association_name"/>
  38. <raise event="start_instance" scope="cd">
  39. <parameter expr="association_name"/>
  40. </raise>
  41. <script>
  42. self.buttons[self.to_create[0]] = association_name
  43. self.to_create.pop(0)
  44. </script>
  45. </transition>
  46. </state>
  47. <state id="pack_button">
  48. <transition event="tk_widget" target="../next_button">
  49. <parameter name="tk_elem"/>
  50. <script>
  51. tk_elem.pack(side=tk.LEFT)
  52. </script>
  53. </transition>
  54. </state>
  55. <state id="next_button">
  56. <transition cond="len(self.to_create) == 0" target="../../root"/>
  57. <transition cond="len(self.to_create) > 0" target="../init_buttons"/>
  58. </state>
  59. </state>
  60. <state id="root">
  61. <transition event="button_pressed" cond="event_name == 'new'" target=".">
  62. <parameter name="event_name"/>
  63. <raise event="create_new_model" scope="narrow" target="'parent'"/>
  64. </transition>
  65. <transition event="button_pressed" cond="event_name == 'open'" target=".">
  66. <parameter name="event_name"/>
  67. <raise event="open_model" scope="narrow" target="'parent'"/>
  68. </transition>
  69. <transition event="close" target="../closing"/>
  70. </state>
  71. <state id="closing">
  72. <onentry>
  73. <raise event="delete_instance" scope="cd">
  74. <parameter expr="self.buttons.popitem()[1]"/>
  75. </raise>
  76. </onentry>
  77. <transition event="instance_deleted" cond="len(self.buttons) > 0" target="../closing"/>
  78. <transition event="instance_deleted" cond="len(self.buttons) == 0" target="../close"/>
  79. </state>
  80. <state id="close">
  81. <onentry>
  82. <raise event="close_window" scope="narrow" target="'parent'"/>
  83. </onentry>
  84. </state>
  85. </scxml>
  86. </class>