def on_open(self, event=None): """ Open binary file with mapmatching data. """ wildcards_all = "All files (*.*)|*.*" wildcards_obj = "Python binary mapmatching files (*.mmatch.obj)|*.mmatch.obj|Python binary files (*.obj)|*.obj" wildcards = wildcards_obj + "|" + wildcards_all # Finally, if the directory is changed in the process of getting files, this # dialog is set up to change the current working directory to the path chosen. dlg = wx.FileDialog( self._mainframe, message="Open mapmatching file", defaultDir=self.get_scenario().get_workdirpath(), #defaultFile = os.path.join(scenario.get_workdirpath(), scenario.format_ident()+'.obj'), wildcard=wildcards, style=wx.OPEN | wx.CHANGE_DIR) # Show the dialog and retrieve the user response. If it is the OK response, # process the data. is_loaded = False if dlg.ShowModal() == wx.ID_OK: # This returns a Python list of files that were selected. filepath = dlg.GetPath() if len(filepath) > 0: if self._mapmatching is not None: # browse away from results # self._mainframe.browse_obj(self._results.get_scenario()) del self._mapmatching self._mapmatching = mapmatching.load_mapmatching( filepath, parent=self.get_scenario(), logger=self._mainframe.get_logger()) is_loaded = True # Destroy the dialog. Don't do this until you are done with it! # BAD things can happen otherwise! dlg.Destroy() if is_loaded: # this should update all widgets for the new scenario!! # print 'call self._mainframe.refresh_moduleguis()' self._mainframe.browse_obj(self._mapmatching) self._is_needs_refresh = True self.refresh_widgets()
def on_open(self, event=None): """ Open binary file with mapmatching data. """ wildcards_all = "All files (*.*)|*.*" wildcards_obj = "Python binary mapmatching files (*.mmatch.obj)|*.mmatch.obj|Python binary files (*.obj)|*.obj" wildcards = wildcards_obj+"|"+wildcards_all # Finally, if the directory is changed in the process of getting files, this # dialog is set up to change the current working directory to the path chosen. dlg = wx.FileDialog( self._mainframe, message="Open mapmatching file", defaultDir=self.get_scenario().get_workdirpath(), #defaultFile = os.path.join(scenario.get_workdirpath(), scenario.format_ident()+'.obj'), wildcard=wildcards, style=wx.OPEN | wx.CHANGE_DIR ) # Show the dialog and retrieve the user response. If it is the OK response, # process the data. is_loaded = False if dlg.ShowModal() == wx.ID_OK: # This returns a Python list of files that were selected. filepath = dlg.GetPath() if len(filepath) > 0: if self._mapmatching is not None: # browse away from results # self._mainframe.browse_obj(self._results.get_scenario()) del self._mapmatching self._mapmatching = mapmatching.load_mapmatching(filepath, parent=self.get_scenario(), logger=self._mainframe.get_logger() ) is_loaded = True # Destroy the dialog. Don't do this until you are done with it! # BAD things can happen otherwise! dlg.Destroy() if is_loaded: # this should update all widgets for the new scenario!! # print 'call self._mainframe.refresh_moduleguis()' self._mainframe.browse_obj(self._mapmatching) self._is_needs_refresh = True self.refresh_widgets()