def testMapDisplay(self, giface, map_): from mapdisp.frame import MapFrame # known issues (should be similar with d.mon): # * opening map in digitizer ends with: vdigit/toolbars.py:723: 'selection' referenced before assignment # * nviz start fails (closes window? segfaults?) after mapdisp/frame.py:306: 'NoneType' object has no attribute 'GetLayerNotebook' frame = MapFrame(parent=None, title=_("Map display test"), giface=giface, Map=map_) # this is questionable: how complete the giface when creating objects # which are in giface giface.mapWindow = frame.GetMapWindow() frame.GetMapWindow().ZoomToMap() frame.Show()
class MapApp(wx.App): def OnInit(self): if not globalvar.CheckWxVersion([2, 9]): wx.InitAllImageHandlers() if __name__ == "__main__": self.cmdTimeStamp = os.path.getmtime(monFile['cmd']) self.Map = Map(cmdfile=monFile['cmd'], mapfile=monFile['map'], envfile=monFile['env'], monitor=monName) else: self.Map = None self.mapFrm = MapFrame(parent=None, id=wx.ID_ANY, Map=self.Map, size=monSize) # self.SetTopWindow(Map) self.mapFrm.Show() if __name__ == "__main__": self.timer = wx.PyTimer(self.watcher) #check each 0.5s global mtime mtime = 500 self.timer.Start(mtime) return True def OnExit(self): if __name__ == "__main__": # stop the timer # self.timer.Stop() # terminate thread for f in monFile.itervalues(): grass.try_remove(f) def watcher(self): """!Redraw, if new layer appears (check's timestamp of cmdfile) """ # todo: events if os.path.getmtime(monFile['cmd']) > self.cmdTimeStamp: self.timer.Stop() self.cmdTimeStamp = os.path.getmtime(monFile['cmd']) self.mapFrm.OnDraw(None) self.mapFrm.GetMap().GetLayersFromCmdFile() self.timer.Start(mtime)