chatwindow.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <class name="ChatWindow">
  2. <relationships>
  3. <inheritance class="tk.Toplevel" priority="1"/>
  4. <inheritance class="SCCDWidget" priority="0"/>
  5. <association name="buttons" class="Button"/>
  6. <association name="entries" class="Entry"/>
  7. <association name="parent" class="A"/>
  8. </relationships>
  9. <constructor>
  10. <parameter name="context"/>
  11. <parameter name="activity_name"/>
  12. <super class="tk.TopLevel"/>
  13. <super class="SCCDWidget"/>
  14. <body>
  15. tk.Label(self, text="Executing %s" % activity_name).pack()
  16. self.input_value = ""
  17. self.context = context
  18. </body>
  19. </constructor>
  20. <destructor>
  21. <body>
  22. self.destroy()
  23. </body>
  24. </destructor>
  25. <scxml initial="get_assoc_name">
  26. <state id="get_assoc_name">
  27. <transition event="assoc_name" target="../init">
  28. <parameter name="assoc_name"/>
  29. <script>
  30. self.assoc_name = assoc_name
  31. </script>
  32. </transition>
  33. </state>
  34. <state id="init" initial="init_entry_log">
  35. <state id="init_entry_log" initial="create">
  36. <state id="create">
  37. <onentry>
  38. <raise event="create_instance" scope="cd">
  39. <parameter expr="'entries'"/>
  40. <parameter expr="'Text'"/>
  41. <parameter expr="{'parent': self, 'name': 'history'}"/>
  42. </raise>
  43. </onentry>
  44. <transition event="instance_created" target="../wait_for_packing">
  45. <parameter name="association_name"/>
  46. <raise event="start_instance" scope="cd">
  47. <parameter expr="association_name"/>
  48. </raise>
  49. <script>
  50. self.entry_log = association_name
  51. </script>
  52. </transition>
  53. </state>
  54. <state id="wait_for_packing">
  55. <transition event="tk_widget" target="../../init_entry_input">
  56. <parameter name="tk_elem"/>
  57. <script>
  58. tk_elem.pack()
  59. </script>
  60. </transition>
  61. </state>
  62. </state>
  63. <state id="init_entry_input" initial="create">
  64. <state id="create">
  65. <onentry>
  66. <raise event="create_instance" scope="cd">
  67. <parameter expr="'entries'"/>
  68. <parameter expr="'Entry'"/>
  69. <parameter expr="{'parent': self, 'value': self.input_value, 'name': 'input_value'}"/>
  70. </raise>
  71. </onentry>
  72. <transition event="instance_created" target="../wait_for_packing">
  73. <parameter name="association_name"/>
  74. <raise event="start_instance" scope="cd">
  75. <parameter expr="association_name"/>
  76. </raise>
  77. <script>
  78. self.entry_input = association_name
  79. </script>
  80. </transition>
  81. </state>
  82. <state id="wait_for_packing">
  83. <transition event="tk_widget" target="../../init_button_send">
  84. <parameter name="tk_elem"/>
  85. <script>
  86. tk_elem.pack()
  87. </script>
  88. </transition>
  89. </state>
  90. </state>
  91. <state id="init_button_send" initial="create">
  92. <state id="create">
  93. <onentry>
  94. <raise event="create_instance" scope="cd">
  95. <parameter expr="'buttons'"/>
  96. <parameter expr="'Button'"/>
  97. <parameter expr="{'parent': self, 'visual': TextVisual('send'), 'tooltip_text': 'Send data to active activity.', 'event_parameters': 'send'}"/>
  98. </raise>
  99. </onentry>
  100. <transition event="instance_created" target="../wait_for_packing">
  101. <parameter name="association_name"/>
  102. <raise event="start_instance" scope="cd">
  103. <parameter expr="association_name"/>
  104. </raise>
  105. <script>
  106. self.button = association_name
  107. </script>
  108. </transition>
  109. </state>
  110. <state id="wait_for_packing">
  111. <transition event="tk_widget" target="../../../root">
  112. <parameter name="tk_elem"/>
  113. <script>
  114. tk_elem.pack()
  115. </script>
  116. </transition>
  117. </state>
  118. </state>
  119. </state>
  120. <state id="root">
  121. <transition event="button_pressed" cond="event_name == 'send'" target=".">
  122. <parameter name="event_name"/>
  123. <raise event="mv_data_input" scope="broad">
  124. <parameter expr="self.input_value"/>
  125. <parameter expr="self.context"/>
  126. </raise>
  127. <script>
  128. print("Sent data to context " + str(self.context))
  129. </script>
  130. <raise event="change_value" scope="narrow" target="self.entry_input">
  131. <parameter expr="''"/>
  132. </raise>
  133. <raise event="append_value" scope="narrow" target="self.entry_log">
  134. <parameter expr="'&lt; ' + self.input_value + '\n'"/>
  135. </raise>
  136. </transition>
  137. <transition event="mv_data_output" target=".">
  138. <parameter name="value"/>
  139. <raise event="append_value" scope="narrow" target="self.entry_log">
  140. <parameter expr="'> ' + value + '\n'"/>
  141. </raise>
  142. </transition>
  143. <transition event="changed_entry" cond="name == 'input_value'" target=".">
  144. <parameter name="name"/>
  145. <parameter name="value"/>
  146. <script>
  147. self.input_value = value
  148. </script>
  149. </transition>
  150. <transition event="close_window" target="../closing"/>
  151. </state>
  152. <state id="closing">
  153. <onentry>
  154. <raise event="delete_instance" scope="cd">
  155. <parameter expr="'buttons'"/>
  156. </raise>
  157. <raise event="delete_instance" scope="cd">
  158. <parameter expr="'entries'"/>
  159. </raise>
  160. </onentry>
  161. <transition event="instance_deleted" target="../close">
  162. <raise event="delete_me" scope="narrow" target="'parent'">
  163. <parameter expr="self.assoc_name"/>
  164. </raise>
  165. </transition>
  166. </state>
  167. <state id="close"/>
  168. </scxml>
  169. </class>