12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <class name="Errorlog">
- <relationships>
- <association name="parent" class="A"/>
- </relationships>
- <constructor>
- <parameter name="constructor_parameters" type='dict' default='{}' />
- <body>
- self.entries = []
- self.parent = constructor_parameters['parent']
- self.entry_timers = []
- </body>
- </constructor>
- <destructor>
- <body>
- for entry in self.entries:
- entry.destroy()
- </body>
- </destructor>
- <scxml initial="main">
- <state id="main" initial='initializing'>
- <state id="initializing">
- <transition target="../ready"/>
- </state>
- <state id="ready">
- <transition event="errorlog_log" target=".">
- <parameter name="new_value"/>
- <script>
- [i.pack_forget() for i in self.entries]
- entry = tk.Label(self.parent, text=new_value, wraplength=150, bg="red", width=30)
- self.entries.append(entry)
- self.entry_timers.append(time.time() + 5)
- [i.pack(anchor=tk.N, fill=tk.X) for i in reversed(self.entries)]
- </script>
- </transition>
- <transition after="max(min(self.entry_timers + [1000 + time.time()]) - time.time(), 0)" target=".">
- <script>
- for i, v in enumerate(self.entry_timers):
- if v < time.time():
- self.entries[i].config(bg="lightgrey")
- self.entry_timers[i] = float('inf')
- </script>
- </transition>
- </state>
- </state>
- </scxml>
- </class>
|