def on_idle(self, event): time.sleep(0.05) now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now self.state.child_pipe_send.send( win_layout.get_wx_window_layout(self))
def on_timer(self, event): '''receive messages from MAVProxy and pass on to GUI''' state = self.state # update saved pos/size of GUI now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now state.child_pipe.send( (win_layout.get_wx_window_layout(self), 0, 0)) if state.close_event.wait(0.001): self.timer.Stop() self.Destroy() return while state.child_pipe.poll(): obj = state.child_pipe.recv() if obj[0] == 'updatelayout': self.updateLayout(obj[1]) elif obj[0] == 'onmavlinkpacket': self.onmavlinkpacket(obj[1]) elif obj[0] == 'updateHB': self.updateHB(obj[1]) elif isinstance(obj[0], win_layout.WinLayout): win_layout.set_wx_window_layout(self, obj[0]) elif obj[0] == 'changesetting' and obj[1][0] == 'takeoffalt': self.updatetakeoffalt(int(obj[1][1]))
def on_idle(self, event): '''prevent the main loop spinning too fast''' state = self.state now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now state.out_queue.put(win_layout.get_wx_window_layout(self)) time.sleep(0.1)
def on_idle(self, event): '''prevent the main loop spinning too fast''' state = self.state now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now state.out_queue.put(win_layout.get_wx_window_layout(self)) time.sleep(0.1)
def on_idle(self, event): now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now self.event_queue.put(win_layout.get_wx_window_layout(self)) obj = None while not self.state.object_queue.empty(): obj = self.state.object_queue.get() if isinstance(obj, win_layout.WinLayout): win_layout.set_wx_window_layout(self, obj)
def on_idle(self, event): '''prevent the main loop spinning too fast''' state = self.state if state.close_window.acquire(False): self.state.app.ExitMainLoop() now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now state.event_queue.put(win_layout.get_wx_window_layout(self)) # receive any display objects from the parent obj = None while not state.object_queue.empty(): obj = state.object_queue.get() if isinstance(obj, win_layout.WinLayout): win_layout.set_wx_window_layout(self, obj) if isinstance(obj, SlipObject): self.add_object(obj) if isinstance(obj, SlipPosition): # move an object object = self.find_object(obj.key, obj.layer) if object is not None: object.update_position(obj) if getattr(object, 'follow', False): self.follow(object) if obj.label is not None: object.label = obj.label if obj.colour is not None: object.colour = obj.colour state.need_redraw = True if isinstance(obj, SlipDefaultPopup): state.default_popup = obj if isinstance(obj, SlipInformation): # see if its a existing one or a new one if obj.key in state.info: # print('update %s' % str(obj.key)) state.info[obj.key].update(obj) else: # print('add %s' % str(obj.key)) state.info[obj.key] = obj state.need_redraw = True if isinstance(obj, SlipCenter): # move center (lat, lon) = obj.latlon state.panel.re_center(state.width / 2, state.height / 2, lat, lon) state.need_redraw = True if isinstance(obj, SlipZoom): # change zoom state.panel.set_ground_width(obj.ground_width) state.need_redraw = True if isinstance(obj, SlipFollow): # enable/disable follow state.follow = obj.enable if isinstance(obj, SlipFollowObject): # enable/disable follow on an object for layer in state.layers: if obj.key in state.layers[layer]: if hasattr(state.layers[layer][obj.key], 'follow'): state.layers[layer][obj.key].follow = obj.enable if isinstance(obj, SlipBrightness): # set map brightness state.brightness = obj.brightness state.need_redraw = True if isinstance(obj, SlipClearLayer): # remove all objects from a layer if obj.layer in state.layers: state.layers.pop(obj.layer) state.need_redraw = True if isinstance(obj, SlipRemoveObject): # remove an object by key for layer in state.layers: if obj.key in state.layers[layer]: state.layers[layer].pop(obj.key) state.need_redraw = True if isinstance(obj, SlipHideObject): # hide an object by key for layer in state.layers: if obj.key in state.layers[layer]: state.layers[layer][obj.key].set_hidden(obj.hide) state.need_redraw = True if state.timelim_pipe is not None: while state.timelim_pipe[1].poll(): try: obj = state.timelim_pipe[1].recv() except Exception: state.timelim_pipe = None break for layer in state.layers: for key in state.layers[layer].keys(): state.layers[layer][key].set_time_range(obj) state.need_redraw = True if obj is None: time.sleep(0.05)
def on_idle(self, event): '''prevent the main loop spinning too fast''' state = self.state if state.close_window.acquire(False): self.state.app.ExitMainLoop() now = time.time() if now - self.last_layout_send > 1: self.last_layout_send = now state.event_queue.put(win_layout.get_wx_window_layout(self)) # receive any display objects from the parent obj = None while not state.object_queue.empty(): obj = state.object_queue.get() if isinstance(obj, win_layout.WinLayout): win_layout.set_wx_window_layout(self, obj) if isinstance(obj, SlipObject): self.add_object(obj) if isinstance(obj, SlipPosition): # move an object object = self.find_object(obj.key, obj.layer) if object is not None: object.update_position(obj) if getattr(object, 'follow', False): self.follow(object) if obj.label is not None: object.label = obj.label if obj.colour is not None: object.colour = obj.colour state.need_redraw = True if isinstance(obj, SlipDefaultPopup): state.default_popup = obj if isinstance(obj, SlipInformation): # see if its a existing one or a new one if obj.key in state.info: # print('update %s' % str(obj.key)) state.info[obj.key].update(obj) else: # print('add %s' % str(obj.key)) state.info[obj.key] = obj state.need_redraw = True if isinstance(obj, SlipCenter): # move center (lat,lon) = obj.latlon state.panel.re_center(state.width/2, state.height/2, lat, lon) state.need_redraw = True if isinstance(obj, SlipZoom): # change zoom state.panel.set_ground_width(obj.ground_width) state.need_redraw = True if isinstance(obj, SlipFollow): # enable/disable follow state.follow = obj.enable if isinstance(obj, SlipFollowObject): # enable/disable follow on an object for layer in state.layers: if obj.key in state.layers[layer]: if hasattr(state.layers[layer][obj.key], 'follow'): state.layers[layer][obj.key].follow = obj.enable if isinstance(obj, SlipBrightness): # set map brightness state.brightness = obj.brightness state.need_redraw = True if isinstance(obj, SlipClearLayer): # remove all objects from a layer if obj.layer in state.layers: state.layers.pop(obj.layer) state.need_redraw = True if isinstance(obj, SlipRemoveObject): # remove an object by key for layer in state.layers: if obj.key in state.layers[layer]: state.layers[layer].pop(obj.key) state.need_redraw = True if isinstance(obj, SlipHideObject): # hide an object by key for layer in state.layers: if obj.key in state.layers[layer]: state.layers[layer][obj.key].set_hidden(obj.hide) state.need_redraw = True if obj is None: time.sleep(0.05)