コード例 #1
0
    def save_stylesheet(self):
        try:
            file_name = "%s.qss" % self.line_name.text()
            if not self._is_valid_scheme_name(file_name):
                QMessageBox.information(self,
                                        translations.TR_PREFERENCES_THEME,
                                        translations.TR_SCHEME_INVALID_NAME)
            file_name = ('{0}.qss'.format(
                file_manager.create_path(resources.NINJA_THEME_DOWNLOAD,
                                         file_name)))
            content = self.edit_qss.toPlainText()
            answer = True
            if file_manager.file_exists(file_name):
                answer = QMessageBox.question(
                    self, translations.TR_PREFERENCES_THEME,
                    translations.TR_WANT_OVERWRITE_FILE +
                    ": {0}?".format(file_name), QMessageBox.Yes,
                    QMessageBox.No)

            if answer in (QMessageBox.Yes, True):
                self.apply_stylesheet()
                file_manager.store_file_content(file_name,
                                                content,
                                                newFile=True)
                self.close()
        except file_manager.NinjaFileExistsException as ex:
            QMessageBox.information(
                self, self.tr("File Already Exists"),
                (self.tr("Invalid File Name: the file '%s' already exists.") %
                 ex.filename))
コード例 #2
0
    def save_scheme(self):
        """Save current scheme."""
        name = self.line_name.text().strip()
        if not self._is_valid_scheme_name(name):
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_SCHEME_INVALID_NAME)
            return
        fileName = ('{0}.color'.format(
            file_manager.create_path(resources.EDITOR_SKINS, name)))
        answer = True
        if file_manager.file_exists(fileName):
            answer = QMessageBox.question(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_WANT_OVERWRITE_FILE +
                ": {0}?".format(fileName), QMessageBox.Yes, QMessageBox.No)

        if answer in (QMessageBox.Yes, True):
            scheme = self._preview_style()
            self.original_style = copy.copy(scheme)
            json_manager.save_editor_skins(fileName, scheme)
            self._modified = False
            self.saved = True
            qsettings = IDE.ninja_settings()
            qsettings.setValue('preferences/editor/scheme', name)
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_SCHEME_SAVED + ": {0}.".format(fileName))
            self.close()
        elif answer == QMessageBox.Yes:
            QMessageBox.information(
                self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
                translations.TR_INVALID_FILENAME)
コード例 #3
0
ファイル: uimain.py プロジェクト: lycying/seeking
    def __evt_close_tab_click(self, index):
        """
        because the first tab is the main window we'll show 
        so we never close it .
        If the tab's content need save , we also remind the user.
        """
        if 0 == index: return

        if hasattr(self.widget(index),
                   "bufferon") and self.widget(index).bufferon():

            reply = QMessageBox.question(
                self, "Save or not?",
                "Save your content first?\n%s" % self.tabText(index),
                QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
            if reply == QMessageBox.Yes:
                if hasattr(self.widget(index), "save"):
                    self.widget(index).save()
                    self.removeTab(index)
                    Seeking().new().emit(SIGNAL('updateWindows()'))
                    return "yes"
            elif reply == QMessageBox.No:
                self.removeTab(index)
                Seeking().new().emit(SIGNAL('updateWindows()'))
                return "no"
            elif reply == QMessageBox.Cancel:
                return "cancel"
        else:
            self.removeTab(index)
            Seeking().new().emit(SIGNAL('updateWindows()'))
            return "yes"
コード例 #4
0
ファイル: uimain.py プロジェクト: lycying/seeking
 def __evt_close_tab_click(self,index):
     """
     because the first tab is the main window we'll show 
     so we never close it .
     If the tab's content need save , we also remind the user.
     """
     if 0 == index :return
     
     if hasattr(self.widget(index),"bufferon") and  self.widget(index).bufferon():
         
             reply = QMessageBox.question(self, "Save or not?",
                 "Save your content first?\n%s" % self.tabText(index),
                 QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
             if reply == QMessageBox.Yes:
                 if hasattr(self.widget(index),"save"):
                     self.widget(index).save()
                     self.removeTab(index)
                     Seeking().new().emit(SIGNAL('updateWindows()'))
                     return "yes"
             elif reply == QMessageBox.No:
                 self.removeTab(index)
                 Seeking().new().emit(SIGNAL('updateWindows()'))
                 return "no"
             elif reply == QMessageBox.Cancel:
                 return "cancel"
     else:
             self.removeTab(index)
             Seeking().new().emit(SIGNAL('updateWindows()'))
             return "yes"
コード例 #5
0
 def reject(self):
     """Reject this dialog."""
     if self._modified:
         answer = QMessageBox.No
         answer = QMessageBox.question(
             self, translations.TR_PREFERENCES_EDITOR_SCHEME_DESIGNER,
             (translations.TR_IDE_CONFIRM_EXIT_TITLE + ".\n" +
              translations.TR_PREFERENCES_GENERAL_CONFIRM_EXIT + "?"),
             QMessageBox.Yes, QMessageBox.No)
         if answer == QMessageBox.No:
             return
     super(EditorSchemeDesigner, self).reject()
コード例 #6
0
ファイル: GUI_EBimage.py プロジェクト: sravel/scripts
	def run(self):
		print("RUN")
		try:
			warning = ""	# initialise le nombre d'erreur
			val = 0			# initialise le nombre d'erreur
			txtInfo = ""

			# import R's "base" package
			base = importr('base')

			with open("fonctions_apprentissage.r", "r", encoding="utf-8") as apprentissageRopen:
				apprentissage = "".join(apprentissageRopen.readlines())
			print(apprentissage)

			apprentissage = SignatureTranslatedAnonymousPackage(apprentissage, "apprentissage")

			#path_sample = "/media/sebastien/Bayer/ScriptsSEB/scripts/GUI/EBimage/AnalyseImagesV2/Samples/5583"
			path_sample = "/".join(str(self.dicoFoldersCallibration["leaf"]).split("/")[:-1])
			print(path_sample)
			print(dir(apprentissage))
			result , pathRdataFile= apprentissage.apprentissage(path_sample).r_repr().replace('"','').replace("c(","").replace(")","").split(",")
			print(result, pathRdataFile)
			if result == "1":
				reply = QMessageBox.question(parent=self, title='Attention', text='File will be overwritten.\nDo you still want to proceed?', buttons=QMessageBox.Yes | QMessageBox.No, defaultButton=QMessageBox.No)
				if reply == QMessageBox.Yes:
					print("OK")
				self.callibrationFileOpenLineEdit.setText(pathRdataFile)
			else:

				print("BAD")


			##grise les boutons pour pas relancer job
			#self.ui.frameRun.show()
			#self.ui.runPushButton.setDisabled(True)
			#self.ui.loadMatriceFilePushButton.setDisabled(True)
			#self.ui.loadOrderFilePushButton.setDisabled(True)
			#self.ui.PCAlineEdit.setDisabled(True)
			#self.ui.DAlineEdit.setDisabled(True)
			#self.ui.popMinLineEdit.setDisabled(True)
			#self.ui.popMaxLineEdit.setDisabled(True)
			#self.ui.rmOldCheckBox.setDisabled(True)
			#self.ui.expertCheckBox.setDisabled(True)
			#self.ui.expertFrame.setDisabled(True)
			#self.ui.graphTypeComboBox.setDisabled(True)
			#if self.expertMode == "True":
				#self.EBimagefix = str(self.ui.EBimagefixPlainTextEdit.toPlainText().toUtf8())
				#self.EBimagechange = str(self.ui.EBimagechangePlainTextEdit.toPlainText().toUtf8())

			#"""to run programme"""
			## création du pathout
			#if os.path.isdir(self.pathFileOut):
				#if self.rmOld == "True":
					#shutil.rmtree(str(self.pathFileOut))
					#os.mkdir(self.pathFileOut)
				#else:
					#warning += "Warnnig folder "+self.pathFileOut+" already exist,\nPlease remove/rename before run new analysis or use checkbox"
					#raise Exception(warning)
			#else:
				#os.mkdir(self.pathFileOut)

			################################################
			## code commun mode graphique ou interface
			################################################

			## charge l'ordre a refaire
			#self.orderList = loadInListCol(self.orderPathFile, 0)

			## copie de la matrice dans un dico
			#self.dicoMatrice = loadInDictLine(self.matricePathFile)

			## Comptage du nombre d'individus, de markers et ncode:
			#self.nbindParam = len(self.dicoMatrice.keys())-1

			#if self.nbindParam != len(self.orderList):
				#txtInfo += "WARNING: More individu in Matrice file (%s) than Order label file (%s)!!!\n" % (self.nbindParam, len(self.orderList))

			#fileMat = open(self.matricePathFile,"r")
			#header = fileMat.readline()
			#self.nbmarkParam = len(header.split("\t"))
			#header = " \t"+"\t".join(header.split("\t")[1:])


			#nbcode = fileMat.readline().split("\t")[1]
			#while nbcode == "-9":
				#nbcode = fileMat.readline().split("\t")[1]
			#self.ncodeParam = len(nbcode)
			#fileMat.close()

			## ouverture du nouveau fichier trier
			#with open(self.pathFileOut+self.basename+"_Reorder.tab","w") as reorderMatriceFile:
				#reorderMatriceFile.write(header)
				#for ind in self.orderList:
					#if ind not in self.dicoMatrice.keys():
						#error = "ERROR: The individu %s define in label file was not in the matrice file !!! Exit programme" % ind
						#raise Exception(error)

					#line = self.dicoMatrice[ind].split("\t")[0]+"\t"+"\t".join(self.dicoMatrice[ind].split("\t")[1:]).replace("999","-9")
					#reorderMatriceFile.write(line)

			#txtInfo += "Nb individus: %i\tNb markers: %i\tncodeParam: %i\tGraph type: %s\n" % (self.nbindParam,int(self.nbmarkParam)-1,self.ncodeParam, self.graphType)
			#if args.cmdMode:
				#pass
			#else:
				#self.ui.runningPlainTextEdit.setPlainText(txtInfo)

			##ouverture du script R
			#Rscript = open(self.pathFileOut+self.basename+"_R_EBimage.R","w")
			#Rscript.write(installPackageR)

			## Ajout du path du fichier matrice dans EBimagefix
			## modifie Script R pour adapter aux parametres rentrés
			#dictToReplace = {
			#"**MAKERS**"	:		str(self.nbmarkParam),
			#"**NCODE**"	:			str(self.ncodeParam),
			#"**INDIV**"	:			str(self.nbindParam),
			#"**PATHTOFILE**":		str(reorderMatriceFile.name),
			#"**current_dir**"	:	str(self.pathFileOut),
			#"**GRAPH**"	:	str(self.graphType)
			#}

			#EBimagefixModif = replace_all(dictToReplace, self.EBimagefix)

			##print(EBimagefixModif)

			#Rscript.write(EBimagefixModif)

			#for pop in range(int(self.popMinValue),int(self.popMaxValue)+1):
				##print(pop)
				#popstr=str(pop)
				#EBimagechange2 = self.EBimagechange.replace("**pop**",popstr).replace("**current_dir**",str(self.pathFileOut)).replace("**PCARETAIN**",str(self.PCAvalue)).replace("**DARETAIN**",str(self.DAvalue))
				##print(EBimagechange2)
				#Rscript.write(EBimagechange2)

			#Rscript.close()
			#self.ui.statusbar.showMessage(str("FINISH, script product on : %s" % self.pathFileOut),9600)

			#txtInfo += "FINISH, script product on :\n %s" % (self.pathFileOut)

			#if args.cmdMode:
				#print(txtInfo)
			#else:
				#self.ui.runningPlainTextEdit.setPlainText(txtInfo)

			## si des erreurs:

		except Exception as e:
			self.displayError(error = e)
コード例 #7
0
ファイル: GUI_EBimage.py プロジェクト: FlorianCHA/scripts
    def run(self):
        print("RUN")
        try:
            warning = ""  # initialise le nombre d'erreur
            val = 0  # initialise le nombre d'erreur
            txtInfo = ""

            # import R's "base" package
            base = importr('base')

            with open("fonctions_apprentissage.r", "r",
                      encoding="utf-8") as apprentissageRopen:
                apprentissage = "".join(apprentissageRopen.readlines())
            print(apprentissage)

            apprentissage = SignatureTranslatedAnonymousPackage(
                apprentissage, "apprentissage")

            #path_sample = "/media/sebastien/Bayer/ScriptsSEB/scripts/GUI/EBimage/AnalyseImagesV2/Samples/5583"
            path_sample = "/".join(
                str(self.dicoFoldersCallibration["leaf"]).split("/")[:-1])
            print(path_sample)
            print(dir(apprentissage))
            result, pathRdataFile = apprentissage.apprentissage(
                path_sample).r_repr().replace('"',
                                              '').replace("c(", "").replace(
                                                  ")", "").split(",")
            print(result, pathRdataFile)
            if result == "1":
                reply = QMessageBox.question(
                    parent=self,
                    title='Attention',
                    text=
                    'File will be overwritten.\nDo you still want to proceed?',
                    buttons=QMessageBox.Yes | QMessageBox.No,
                    defaultButton=QMessageBox.No)
                if reply == QMessageBox.Yes:
                    print("OK")
                self.callibrationFileOpenLineEdit.setText(pathRdataFile)
            else:

                print("BAD")

            ##grise les boutons pour pas relancer job
            #self.ui.frameRun.show()
            #self.ui.runPushButton.setDisabled(True)
            #self.ui.loadMatriceFilePushButton.setDisabled(True)
            #self.ui.loadOrderFilePushButton.setDisabled(True)
            #self.ui.PCAlineEdit.setDisabled(True)
            #self.ui.DAlineEdit.setDisabled(True)
            #self.ui.popMinLineEdit.setDisabled(True)
            #self.ui.popMaxLineEdit.setDisabled(True)
            #self.ui.rmOldCheckBox.setDisabled(True)
            #self.ui.expertCheckBox.setDisabled(True)
            #self.ui.expertFrame.setDisabled(True)
            #self.ui.graphTypeComboBox.setDisabled(True)
            #if self.expertMode == "True":
            #self.EBimagefix = str(self.ui.EBimagefixPlainTextEdit.toPlainText().toUtf8())
            #self.EBimagechange = str(self.ui.EBimagechangePlainTextEdit.toPlainText().toUtf8())

            #"""to run programme"""
            ## création du pathout
            #if os.path.isdir(self.pathFileOut):
            #if self.rmOld == "True":
            #shutil.rmtree(str(self.pathFileOut))
            #os.mkdir(self.pathFileOut)
            #else:
            #warning += "Warnnig folder "+self.pathFileOut+" already exist,\nPlease remove/rename before run new analysis or use checkbox"
            #raise Exception(warning)
            #else:
            #os.mkdir(self.pathFileOut)

            ################################################
            ## code commun mode graphique ou interface
            ################################################

            ## charge l'ordre a refaire
            #self.orderList = loadInListCol(self.orderPathFile, 0)

            ## copie de la matrice dans un dico
            #self.dicoMatrice = loadInDictLine(self.matricePathFile)

            ## Comptage du nombre d'individus, de markers et ncode:
            #self.nbindParam = len(self.dicoMatrice.keys())-1

            #if self.nbindParam != len(self.orderList):
            #txtInfo += "WARNING: More individu in Matrice file (%s) than Order label file (%s)!!!\n" % (self.nbindParam, len(self.orderList))

            #fileMat = open(self.matricePathFile,"r")
            #header = fileMat.readline()
            #self.nbmarkParam = len(header.split("\t"))
            #header = " \t"+"\t".join(header.split("\t")[1:])

            #nbcode = fileMat.readline().split("\t")[1]
            #while nbcode == "-9":
            #nbcode = fileMat.readline().split("\t")[1]
            #self.ncodeParam = len(nbcode)
            #fileMat.close()

            ## ouverture du nouveau fichier trier
            #with open(self.pathFileOut+self.basename+"_Reorder.tab","w") as reorderMatriceFile:
            #reorderMatriceFile.write(header)
            #for ind in self.orderList:
            #if ind not in self.dicoMatrice.keys():
            #error = "ERROR: The individu %s define in label file was not in the matrice file !!! Exit programme" % ind
            #raise Exception(error)

            #line = self.dicoMatrice[ind].split("\t")[0]+"\t"+"\t".join(self.dicoMatrice[ind].split("\t")[1:]).replace("999","-9")
            #reorderMatriceFile.write(line)

            #txtInfo += "Nb individus: %i\tNb markers: %i\tncodeParam: %i\tGraph type: %s\n" % (self.nbindParam,int(self.nbmarkParam)-1,self.ncodeParam, self.graphType)
            #if args.cmdMode:
            #pass
            #else:
            #self.ui.runningPlainTextEdit.setPlainText(txtInfo)

            ##ouverture du script R
            #Rscript = open(self.pathFileOut+self.basename+"_R_EBimage.R","w")
            #Rscript.write(installPackageR)

            ## Ajout du path du fichier matrice dans EBimagefix
            ## modifie Script R pour adapter aux parametres rentrés
            #dictToReplace = {
            #"**MAKERS**"	:		str(self.nbmarkParam),
            #"**NCODE**"	:			str(self.ncodeParam),
            #"**INDIV**"	:			str(self.nbindParam),
            #"**PATHTOFILE**":		str(reorderMatriceFile.name),
            #"**current_dir**"	:	str(self.pathFileOut),
            #"**GRAPH**"	:	str(self.graphType)
            #}

            #EBimagefixModif = replace_all(dictToReplace, self.EBimagefix)

            ##print(EBimagefixModif)

            #Rscript.write(EBimagefixModif)

            #for pop in range(int(self.popMinValue),int(self.popMaxValue)+1):
            ##print(pop)
            #popstr=str(pop)
            #EBimagechange2 = self.EBimagechange.replace("**pop**",popstr).replace("**current_dir**",str(self.pathFileOut)).replace("**PCARETAIN**",str(self.PCAvalue)).replace("**DARETAIN**",str(self.DAvalue))
            ##print(EBimagechange2)
            #Rscript.write(EBimagechange2)

            #Rscript.close()
            #self.ui.statusbar.showMessage(str("FINISH, script product on : %s" % self.pathFileOut),9600)

            #txtInfo += "FINISH, script product on :\n %s" % (self.pathFileOut)

            #if args.cmdMode:
            #print(txtInfo)
            #else:
            #self.ui.runningPlainTextEdit.setPlainText(txtInfo)

            ## si des erreurs:

        except Exception as e:
            self.displayError(error=e)