예제 #1
0
파일: main.py 프로젝트: McStasMcXtrace/ufit
 def _get_export_filename(self, filter='ASCII text (*.txt)'):
     initialdir = session.props.get('lastexportdir', session.dirname)
     filename, _ = QFileDialog.getSaveFileName(self,
                                               'Select export file name',
                                               initialdir, filter)
     if filename == '':
         return ''
     expfilename = path_to_str(filename)
     session.props.lastexportdir = path.dirname(expfilename)
     return expfilename
예제 #2
0
파일: main.py 프로젝트: McStasMcXtrace/ufit
 def on_actionInsert_triggered(self):
     initialdir = session.dirname
     if not initialdir:
         with self.sgroup as settings:
             initialdir = settings.value('loadfiledirectory', '')
     filename, _ = QFileDialog.getOpenFileName(self, 'Select file name',
                                               initialdir,
                                               'ufit files (*.ufit)')
     if filename == '':
         return
     self.insert_session(path_to_str(filename))
예제 #3
0
 def on_settemplateBtn_clicked(self):
     previous = self.templateEdit.text()
     if previous:
         startdir = path.dirname(previous)
     else:
         startdir = '.'
     fn = path_to_str(
         QFileDialog.getOpenFileName(self, 'Choose a file', startdir,
                                     'All files (*)')[0])
     if not fn:
         return
     dtempl, numor = extract_template(fn)
     self.set_template(dtempl, numor)
예제 #4
0
    def changeDir(self):
        """ Change directory from which are the data read  """

        if self.dir:
            startdir = self.dir
        else:
            startdir = '.'
        fn = path_to_str(QFileDialog.getOpenFileName(
            self, 'Choose a file', startdir, 'All files (*)')[0])
        if not fn:
            return
        dtempl, numor = extract_template(fn)
        self.dir = dtempl
        self.ui.txtNumors.setText(str(numor))
        print("directory changed to", self.dir)
예제 #5
0
파일: main.py 프로젝트: McStasMcXtrace/ufit
 def save_session_as(self):
     initialdir = session.dirname
     filename, _ = QFileDialog.getSaveFileName(self, 'Select file name',
                                               initialdir,
                                               'ufit files (*.ufit)')
     if filename == '':
         return False
     session.set_filename(path_to_str(filename))
     try:
         session.save()
     except Exception as err:
         logger.exception('Saving session failed')
         QMessageBox.warning(self, 'Error', 'Saving failed: %s' % err)
         return False
     return True
예제 #6
0
 def open_data(self, final=False):
     try:
         prec = float(self.precisionEdit.text())
     except ValueError:
         QMessageBox.information(self, 'Error', 'Enter a valid precision.')
         return
     floatmerge = self.rbFloatMerge.isChecked()
     xcol = str(self.xcolBox.currentText())
     ycol = str(self.ycolBox.currentText())
     dycol = str(self.dycolBox.currentText())
     mcol = str(self.moncolBox.currentText())
     fcol = str(self.filtercolBox.currentText())
     if mcol == 'none':
         mcol = None
     if dycol == 'sqrt(Y)':
         dycol = None
     try:
         mscale = int(self.monscaleEdit.text())
     except Exception:
         QMessageBox.information(self, 'Error',
                                 'Monitor scale must be integer.')
         return
     if fcol == 'none':
         filter = None
     else:
         try:
             val = float(self.filtervalEdit.text())
         except ValueError:
             val = bytes(self.filtervalEdit.text(), 'utf-8')
         filter = {fcol: val}
     dtempl = path_to_str(self.templateEdit.text())
     self.loader.template = dtempl
     numors = str(self.numorsEdit.text())
     try:
         datas = self.loader.load_numors(numors, prec, xcol, ycol, dycol,
                                         mcol, mscale, floatmerge, filter)
     except Exception as e:
         self.logger.exception('Error while loading data file')
         QMessageBox.information(self, 'Error', str(e))
         return
     self.last_data = datas
     if final:
         self.newDatas.emit(datas, self.groupBox.currentText())
         self.closeRequest.emit()
     else:
         self.plot()
예제 #7
0
 def on_dirBtn_clicked(self):
     newdir = QFileDialog.getExistingDirectory(self, 'New directory',
                                               self.rootdir)
     self.set_directory(path_to_str(newdir))
예제 #8
0
 def on_browseBtn_clicked(self):
     templ = path_to_str(self.templateEdit.text())
     self.open_browser(path.dirname(templ))