def showStatusMsg(self,context,msg): context_id=self.statusbar.get_context_id(context) msg_id=self.statusbar.push(context_id,msg) timeout=tasklet.WaitForTimeout(1000) yield timeout self.statusbar.remove(context_id,msg_id) # See >>> # "remove" depreciated in later GTK version, so in future use >>> #self.statusbar.remove_message(context_id,msg_id) tasklet.get_event()
def refreshSensors(self): while self.burstModeOnOff: timeout = tasklet.WaitForTimeout(self.refreshRate) for i in range(8): if self.checkbuttonSensors[i].get_active() and self.burstModeOnOff: value=self.get_sensor_value(i) if value>-1: self.sensorValues[i]=value self.entrySensors[i].set_text(self.get_sensor_text(i,value)) self.sensorBars[i].set_fraction(self.sensorValues[i]/1023.0) yield timeout tasklet.get_event()
def run(self): timeout = tasklet.WaitForTimeout(1000) msgwait = tasklet.WaitForMessages(accept='quit') for i in range(10, 0, -1): self.dialog.format_secondary_markup( "Time left: <b>%i</b> seconds" % i) yield timeout, msgwait ev = tasklet.get_event() if isinstance(ev, tasklet.Message) and ev.name == 'quit': return elif ev is timeout: pass else: raise AssertionError
def process_stdout_sink(chan, buffer, view): timeout = tasklet.WaitForTimeout(200) iowait = tasklet.WaitForIO(chan, priority=1000) msgwait = tasklet.WaitForMessages(accept='quit') while True: yield iowait, msgwait ev = tasklet.get_event() if isinstance(ev, tasklet.Message) and ev.name == 'quit': return assert ev is iowait text = chan.read() buffer.insert(buffer.get_end_iter(), text) view.scroll_to_mark(buffer.get_insert(), 0) ## Now wait for some time, don't let process output "drown" ## the TextView updates yield timeout, tasklet.WaitForMessages(defer='quit') ev = tasklet.get_event() assert ev is timeout
def some_task(): yield tasklet.WaitForTimeout(100) tasklet.get_event() raise StopIteration("return-val")