Esempio n. 1
0
 def savePlot(self):
     saveName = None
     dialog = QFileDialog(self, "Select file name", "", self._saveTypes)
     dialog.selectNameFilter(gr.PRINT_TYPE[gr.PRINT_PDF])
     dialog.setOption(dialog.HideNameFilterDetails, False)
     dialog.setAcceptMode(QFileDialog.AcceptSave)
     if dialog.exec_() == QDialog.Accepted:
         path = dialog.selectedFiles()[0]
         if path:
             _p, suffix = os.path.splitext(path)
             if suffix:
                 suffix = suffix.lower()
             else:
                 # append selected name filter suffix (filename extension)
                 nameFilter = dialog.selectedNameFilter()
                 for k, v in gr.PRINT_TYPE.items():
                     if v == nameFilter:
                         suffix = '.' + k
                         path += suffix
                         break
             if suffix and (suffix[1:] in gr.PRINT_TYPE
                            or suffix[1:] in gr.GRAPHIC_TYPE):
                 self.save(path)
                 saveName = os.path.basename(path)
                 self._saveName = saveName
             else:
                 raise Exception("Unsupported file format")
     return saveName
Esempio n. 2
0
 def on_script_path_button_clicked(self):
     dialog = QFileDialog(self)
     dialog.setFileMode(QFileDialog.DirectoryOnly)
     if dialog.exec_() == QDialog.Accepted:
         scriptpath = dialog.selectedFiles()[0]
         self.client.run(f'Exp.scriptpath = "{scriptpath}"')
         self.scriptPathLine.setText(scriptpath)