def browse(self): filechooser = FileChooser(mforms.SaveFile) filechooser.set_directory( os.path.dirname(self.exportfile_path.get_string_value())) extensions = [] for module in self.main.formats: extensions.append(module.get_file_extension()[0]) filechooser.set_extensions("|".join(extensions), self.active_module.get_file_extension()[1], False) if filechooser.run_modal(): file_path = filechooser.get_path() self.exportfile_path.set_value(file_path) self.destination_file_checked = True global last_location last_location = file_path self.confirm_file_overwrite = False self.get_module() for opt in self.radio_opts: if self.active_module and opt[ 'name'] == self.active_module.name: opt['radio'].set_active(True) self.load_module_options()
def open_file_chooser(self, file_chooser_type, textfield): filechooser = FileChooser(file_chooser_type) filechooser.set_directory(textfield.get_string_value()) if filechooser.run_modal(): filename = filechooser.get_directory() if filename and (type(filename) is str or type(filename) is unicode): filename = filename.replace("\\", "/") # TODO: Check for backslashed spaces and so on textfield.set_value(filename)
def open_file_chooser(self, file_chooser_type, textfield, name): filechooser = FileChooser(file_chooser_type) filechooser.set_directory(textfield.get_string_value()) if filechooser.run_modal(): filename = filechooser.get_directory() if filename and (type(filename) is str or type(filename) is unicode): filename = filename.replace("\\", "/") # TODO: Check for backslashed spaces and so on textfield.set_value("\"" + filename + "\"") self.control_action(name)
def importfile_browse(self): filechooser = FileChooser(mforms.OpenFile) filechooser.set_directory(os.path.dirname(self.importfile_path.get_string_value())) extensions = [] for module in self.main.formats: extensions.append(module.get_file_extension()[0]) filechooser.set_extensions("|".join(extensions), self.main.formats[0].get_file_extension()[1], False) if filechooser.run_modal(): file_path = filechooser.get_path() self.importfile_path.set_value(file_path) global last_location last_location = file_path
def shapefile_browse(self): filechooser = FileChooser(mforms.OpenFile) filechooser.set_directory(os.path.dirname(self.shapefile_path.get_string_value())) filechooser.set_extensions("Spatial Shape File (*.shp)|*.shp", "shp"); if filechooser.run_modal(): filepath = filechooser.get_path() filename = os.path.splitext(os.path.basename(filepath))[0] self.shapefile_path.set_value(filepath) if os.path.isfile("".join([os.path.dirname(filepath),"/",filename,".dbf"])): self.dbf_icon.set_image("task_checked%s.png" % os_icon_suffix) else: self.dbf_icon.set_image("task_warning%s.png" % os_icon_suffix) if os.path.isfile("".join([os.path.dirname(filepath),"/",filename,".prj"])): self.proj_icon.set_image("task_checked%s.png" % os_icon_suffix) else: self.proj_icon.set_image("task_warning%s.png" % os_icon_suffix) self.warning_srs.set_text("Projection file not found, assuming WGS84 Spatial Reference System")
def browse(self): filechooser = FileChooser(mforms.SaveFile) filechooser.set_directory(os.path.dirname(self.exportfile_path.get_string_value())) extensions = [] for module in self.main.formats: extensions.append(module.get_file_extension()[0]) filechooser.set_extensions("|".join(extensions), self.active_module.get_file_extension()[1], False) if filechooser.run_modal(): file_path = filechooser.get_path() self.exportfile_path.set_value(file_path) self.destination_file_checked = True global last_location last_location = file_path self.confirm_file_overwrite = False self.get_module() for opt in self.radio_opts: if self.active_module and opt['name'] == self.active_module.name: opt['radio'].set_active(True) self.load_module_options()