diff --git a/PHYMOBAT.py b/PHYMOBAT.py index aa72225d6059a850c90a7fd3c6ddf70eaeab6fe8..a6505a033d41ed948001bc4178eb0c3ad7c457db 100644 --- a/PHYMOBAT.py +++ b/PHYMOBAT.py @@ -354,21 +354,21 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): """ Open a input browser box to select the VHRS image path by line edit. """ - orthofilename = QtWidgets.QFileDialog.getOpenFileName(self, "THRS image", self.ui.lineEdit_principal_folder.text(), '*.TIF *.tif') + orthofilename = QtWidgets.QFileDialog.getOpenFileName(self, "THRS image", self.ui.lineEdit_principal_folder.text(), '*.TIF *.tif')[0] self.ui.lineEdit_VHRS.setText(str(orthofilename).replace('[','').replace(']','').replace(' ','')) def f_path_mnt(self): """ Open a input browser box to select the MNT image path by line edit. """ - mntfilename = QtWidgets.QFileDialog.getOpenFileName(self, "MNT image", self.ui.lineEdit_principal_folder.text(), '*.TIF *.tif') + mntfilename = QtWidgets.QFileDialog.getOpenFileName(self, "MNT image", self.ui.lineEdit_principal_folder.text(), '*.TIF *.tif')[0] self.ui.lineEdit_MNT.setText(str(mntfilename).replace('[','').replace(']','').replace(' ','')) def f_path_area(self): """ Open a input browser box to select the study area shapefile path by line edit. """ - areafilename = QtWidgets.QFileDialog.getOpenFileName(self, "Area shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp') + areafilename = QtWidgets.QFileDialog.getOpenFileName(self, "Area shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp')[0] self.ui.lineEdit_area_path.setText(str(areafilename).replace('[','').replace(']','').replace(' ','')) def f_proxy(self): @@ -383,14 +383,14 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): """ Open a input browser box to select segmentation shapefile path path by line edit. """ - segmfilename = QtWidgets.QFileDialog.getOpenFileName(self, "Segmentation shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp') + segmfilename = QtWidgets.QFileDialog.getOpenFileName(self, "Segmentation shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp')[0] self.ui.lineEdit_segmentation.setText(str(segmfilename).replace('[','').replace(']','').replace(' ','')) def f_output_name_moba(self): """ Set the output classification shapefile path by line edit. """ - outfilename = QtWidgets.QFileDialog.getSaveFileName(self, "FB file", self.ui.lineEdit_principal_folder.text(), '*.shp') + outfilename = QtWidgets.QFileDialog.getSaveFileName(self, "FB file", self.ui.lineEdit_principal_folder.text(), '*.shp')[0] #Â if the user has forgotten to put .shp at the end of the output shapefile if outfilename[-4:] != '.shp': outfilename = outfilename + '.shp' @@ -401,7 +401,7 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): Open a input browser box to select the sample shapefile path by line edit. With :func:`add_sample` conditions for the expert mode. For the simply mode, this function is used for the RPG shapefile. """ - samplefilename = QtWidgets.QFileDialog.getOpenFileName(self, "Sample shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp') + samplefilename = QtWidgets.QFileDialog.getOpenFileName(self, "Sample shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp')[0] self.ui.lineEdit_sample_path.setText(str(samplefilename).replace('[','').replace(']','').replace(' ','')) def enter_sample_name_hl(self): @@ -409,21 +409,21 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): Open a input browser box to select the grass and wooden sample shapefile path by line edit. With :func:`add_sample` conditions for the simply mode. """ - samplefilename_hl = QtWidgets.QFileDialog.getOpenFileName(self, "Grass/Wooden sample shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp') + samplefilename_hl = QtWidgets.QFileDialog.getOpenFileName(self, "Grass/Wooden sample shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp')[0] self.ui.lineEdit_sample_path_2.setText(str(samplefilename_hl).replace('[','').replace(']','').replace(' ','')) def enter_sample_name_ll(self): """ Open a input browser box to select the wooden sample shapefile path by line edit. With :func:`add_sample` conditions for the simply mode. """ - samplefilename_ll = QtWidgets.QFileDialog.getOpenFileName(self, "Wooden sample shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp') + samplefilename_ll = QtWidgets.QFileDialog.getOpenFileName(self, "Wooden sample shapefile", self.ui.lineEdit_principal_folder.text(), '*.shp')[0] self.ui.lineEdit_sample_path_3.setText(str(samplefilename_ll).replace('[','').replace(']','').replace(' ','')) def img_sample_name(self): """ Open a input browser box to select the image for samples path by line edit. With :func:`add_sample` conditions. """ - imgsamplefilename = QtWidgets.QFileDialog.getOpenFileName(self, "Sample image", self.ui.lineEdit_principal_folder.text(), '*.TIF') + imgsamplefilename = QtWidgets.QFileDialog.getOpenFileName(self, "Sample image", self.ui.lineEdit_principal_folder.text(), '*.TIF')[0] self.ui.lineEdit_img_sample.setText(str(imgsamplefilename).replace('[','').replace(']','').replace(' ','')) def add_sample(self): @@ -1009,7 +1009,7 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): Function to load input text in every fields. The input file must be a XML file. """ - in_backup = QtWidgets.QFileDialog.getOpenFileName(self, "Open backup", os.getcwd(), '*.xml') + in_backup = QtWidgets.QFileDialog.getOpenFileName(self, "Open backup", os.getcwd(), '*.xml')[0] if in_backup != None and len(in_backup) > 0 : @@ -1022,17 +1022,21 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): self.ui.checkBox_multiprocess.setChecked(False) pr = tree.find("Tab[@id='Processing_raster']") + try: self.ui.lineEdit_principal_folder.setText(pr.find("Principal_folder").text) except: print('Not principal folder') + if self.mode == 1: index_captor = self.ui.comboBox_captor.findText(pr.find("Captor").text) #Â To find combo box index self.ui.comboBox_captor.setCurrentIndex(index_captor) + try: self.ui.lineEdit_year_images.setText(pr.find("Year_images").text) except: print('Not year images') + self.ui.lineEdit_area_path.setText(pr.find("Area_path").text) if self.mode == 1: @@ -1193,17 +1197,13 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): self.ui.radioButton_rf.setChecked(True) else: self.ui.radioButton_s.setChecked(True) - - print("Load input text !") - + def save_backup(self): """ Function to save input text in every fields. The output file must be a XML file. """ - out_backup = QtWidgets.QFileDialog.getSaveFileName(self, "Save backup", os.getcwd(), '*.xml') - - print(out_backup) + out_backup = QtWidgets.QFileDialog.getSaveFileName(self, "Save backup", os.getcwd(), '*.xml')[0] #Â if the user has forgotten to put .shp at the end of the output xml if out_backup[-4:] != '.xml': @@ -1386,8 +1386,6 @@ class PHYMOBAT(QtWidgets.QMainWindow, Processing): tree = ET.ElementTree(root) #Â Write in a xml file tree.write(str(out_backup), encoding="UTF-8",xml_declaration=True, pretty_print=True) - if out_backup != '.xml': - print("Save input text !") def about_PHYMOBA(self): """