def on_clean_osm(self, event=None): scenario = self.get_scenario() wildcards_all = "All files (*.*)|*.*" wildcards_xml = "Poly xml files (*.osm.xml)|*.osm.xml|XML files (*.xml)|*.xml" wildcards = wildcards_xml + "|" + 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="Choose one or more osm files to clean", defaultDir=scenario.get_workdirpath(), defaultFile=os.path.join(scenario.get_workdirpath( ), scenario.get_rootfilename() + 'osm.xml'), wildcard=wildcards, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR ) # Show the dialog and retrieve the user response. If it is the OK response, # process the data. if dlg.ShowModal() == wx.ID_OK: # This returns a Python list of files that were selected. paths = dlg.GetPaths() # print 'You selected %d files:' % len(paths) if len(paths) > 0: for path in paths: # print ' %s' % path path_temp = path + '.clean' landuse.clean_osm(path, path_temp) #shutil.copy (path_temp, path) shutil.move(path_temp, path) self._mainframe.browse_obj(self._landuse) self._mainframe.refresh_moduleguis() # inform plugins # Destroy the dialog. Don't do this until you are done with it! # BAD things can happen otherwise! dlg.Destroy()
def on_clean_osm(self, event=None): scenario = self.get_scenario() wildcards_all = "All files (*.*)|*.*" wildcards_xml = "Poly xml files (*.osm.xml)|*.osm.xml|XML files (*.xml)|*.xml" wildcards = wildcards_xml + "|" + 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="Choose one or more osm files to clean", defaultDir=scenario.get_workdirpath(), defaultFile=os.path.join( scenario.get_workdirpath(), scenario.get_rootfilename() + 'osm.xml'), wildcard=wildcards, style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR) # Show the dialog and retrieve the user response. If it is the OK response, # process the data. if dlg.ShowModal() == wx.ID_OK: # This returns a Python list of files that were selected. paths = dlg.GetPaths() # print 'You selected %d files:' % len(paths) if len(paths) > 0: for path in paths: # print ' %s' % path path_temp = path + '.clean' landuse.clean_osm(path, path_temp) #shutil.copy (path_temp, path) shutil.move(path_temp, path) self._mainframe.browse_obj(self._landuse) self._mainframe.refresh_moduleguis() # inform plugins # Destroy the dialog. Don't do this until you are done with it! # BAD things can happen otherwise! dlg.Destroy()