예제 #1
0
 def saveAction(self):
     """Save the plot into a file,
     after asking the directory where to save them
     """
     savePath = askDirName(self, igstr.whereSavePlots)
     if savePath != "":
         try:
             self.parent().lastAuthorStats["figs"] = pBStats.plotStats(
                 author=True, save=True, path=savePath)
         except AttributeError:
             pBGUILogger.warning("", exc_info=True)
         else:
             infoMessage(igstr.plotsSaved)
             self.saveButton.setDisabled(True)
예제 #2
0
 def populateAskExp(self):
     """If selection of experiments is allowed, add some information
     on the bibtex/category for which the experiments are requested
     and a simple message, then create few required empty lists
     """
     if self.askExps:
         if self.askForBib is not None:
             try:
                 bibitem = pBDB.bibs.getByBibkey(self.askForBib, saveQuery=False)[0]
             except IndexError:
                 pBGUILogger.warning(
                     ewstr.entryNotInDb % self.askForBib,
                     exc_info=True,
                 )
                 return
             try:
                 if bibitem["inspire"] != "" and bibitem["inspire"] is not None:
                     link = "<a href='%s'>%s</a>" % (
                         pBView.getLink(self.askForBib, "inspire"),
                         self.askForBib,
                     )
                 elif bibitem["arxiv"] != "" and bibitem["arxiv"] is not None:
                     link = "<a href='%s'>%s</a>" % (
                         pBView.getLink(self.askForBib, "arxiv"),
                         self.askForBib,
                     )
                 elif bibitem["doi"] != "" and bibitem["doi"] is not None:
                     link = "<a href='%s'>%s</a>" % (
                         pBView.getLink(self.askForBib, "doi"),
                         self.askForBib,
                     )
                 else:
                     link = self.askForBib
                 bibtext = PBLabel(
                     ewstr.markExpKAT % (link, bibitem["author"], bibitem["title"])
                 )
             except KeyError:
                 bibtext = PBLabel(ewstr.markExpK % (self.askForBib))
             self.currLayout.addWidget(bibtext)
         elif self.askForCat is not None:
             raise NotImplementedError(ewstr.featureNYI)
         else:
             self.currLayout.addWidget(PBLabel(ewstr.selectDesired))
         self.marked = []
         self.parent().selectedExps = []
     return True
예제 #3
0
    def initUI(self):
        """Create and fill the `QGridLayout`"""
        self.setWindowTitle(dwstr.config)

        grid = QGridLayout()
        self.grid = grid
        grid.setSpacing(1)

        i = 0
        for k in pbConfig.paramOrder:
            i += 1
            val = (pbConfig.params[k]
                   if isinstance(pbConfig.params[k], six.string_types) else
                   str(pbConfig.params[k]))
            grid.addWidget(
                PBLabel("%s (<i>%s</i>%s)" % (
                    configuration_params[k].description,
                    k,
                    (" - " + dwstr.globalSett)
                    if configuration_params[k].isGlobal else "",
                )),
                i - 1,
                0,
                1,
                2,
            )
            if k == "bibtexListColumns":
                self.textValues.append([k, QPushButton(val)])
                self.textValues[-1][1].clicked.connect(self.editColumns)
            elif k == "pdfFolder":
                self.textValues.append([k, QPushButton(val)])
                self.textValues[-1][1].clicked.connect(self.editPDFFolder)
            elif k == "loggingLevel":
                try:
                    self.textValues.append([
                        k,
                        PBComboBox(
                            self,
                            pbConfig.loggingLevels,
                            pbConfig.loggingLevels[int(val)],
                        ),
                    ])
                except (IndexError, ValueError):
                    pBGUILogger.warning(dwstr.invalidLoggingLevel)
                    self.textValues.append([
                        k,
                        PBComboBox(
                            self,
                            pbConfig.loggingLevels,
                            pbConfig.loggingLevels[int(
                                configuration_params["loggingLevel"].default)],
                        ),
                    ])
            elif k == "logFileName":
                self.textValues.append([k, QPushButton(val)])
                self.textValues[-1][1].clicked.connect(self.editFile)
            elif k == "defaultCategories":
                self.textValues.append([k, QPushButton(val)])
                self.textValues[-1][1].clicked.connect(self.editDefCats)
            elif configuration_params[k].special == "boolean":
                self.textValues.append([k, PBTrueFalseCombo(self, val)])
            else:
                self.textValues.append([k, QLineEdit(val)])
            grid.addWidget(self.textValues[i - 1][1], i - 1, 2, 1, 2)

        # OK button
        self.acceptButton = QPushButton(dwstr.ok, self)
        self.acceptButton.clicked.connect(self.onOk)
        # width = self.acceptButton.fontMetrics().boundingRect('OK').width() + 7
        # self.acceptButton.setMaximumWidth(width)
        grid.addWidget(self.acceptButton, i, 0)

        # cancel button
        self.cancelButton = QPushButton(dwstr.cancel, self)
        self.cancelButton.clicked.connect(self.onCancel)
        self.cancelButton.setAutoDefault(True)
        # width = self.cancelButton.fontMetrics().boundingRect('Cancel').width() + 7
        # self.cancelButton.setMaximumWidth(width)
        grid.addWidget(self.cancelButton, i, 1)

        self.setGeometry(100, 100, 1000, 30 * i)
        self.setLayout(grid)
예제 #4
0
 def populateAskCat(self):
     """If selection of categories is allowed, add some information
     on the bibtex/experiment for which the categories are requested
     and a simple message, then create few required empty lists
     """
     if self.askCats:
         if self.askForBib is not None:
             try:
                 bibitem = pBDB.bibs.getByBibkey(self.askForBib,
                                                 saveQuery=False)[0]
             except IndexError:
                 pBGUILogger.warning(
                     cwstr.entryNotInDb % self.askForBib,
                     exc_info=True,
                 )
                 return
             try:
                 if bibitem["inspire"] != "" and bibitem[
                         "inspire"] is not None:
                     link = "<a href='%s'>%s</a>" % (
                         pBView.getLink(self.askForBib, "inspire"),
                         self.askForBib,
                     )
                 elif bibitem["arxiv"] != "" and bibitem[
                         "arxiv"] is not None:
                     link = "<a href='%s'>%s</a>" % (
                         pBView.getLink(self.askForBib, "arxiv"),
                         self.askForBib,
                     )
                 elif bibitem["doi"] != "" and bibitem["doi"] is not None:
                     link = "<a href='%s'>%s</a>" % (
                         pBView.getLink(self.askForBib, "doi"),
                         self.askForBib,
                     )
                 else:
                     link = self.askForBib
                 bibtext = PBLabel(
                     cwstr.markCatBibKAT %
                     (link, bibitem["author"], bibitem["title"]))
             except KeyError:
                 bibtext = PBLabel(cwstr.markCatBibK % (self.askForBib))
             self.currLayout.addWidget(bibtext)
         elif self.askForExp is not None:
             try:
                 expitem = pBDB.exps.getByID(self.askForExp)[0]
             except IndexError:
                 pBGUILogger.warning(
                     cwstr.expNotInDb % self.askForExp,
                     exc_info=True,
                 )
                 return
             try:
                 exptext = PBLabel(
                     cwstr.markCatExpINC %
                     (self.askForExp, expitem["name"], expitem["comments"]))
             except KeyError:
                 exptext = PBLabel(cwstr.markCatExpI % (self.askForExp))
             self.currLayout.addWidget(exptext)
         else:
             if self.single:
                 comment = PBLabel(cwstr.selectCat)
             else:
                 comment = PBLabel(cwstr.selectCats)
             self.currLayout.addWidget(comment)
         self.marked = []
         self.parent().selectedCats = []
     return True