Example #1
0
 def on_actionLoadPAD_triggered(self):
     filename = QFileDialog.getOpenFileName(self,
         'Open PAD File', '', 'PAD File (*.pad *.PAD);;All files (*)')[0]
     if filename:
         self.widget.LoadPadFile(filename)
         self.updateRange()
         self.add_to_flist(filename, 'pad')
Example #2
0
 def on_actionLoadTOF_triggered(self):
     filename = QFileDialog.getOpenFileName(
         self, 'Open TOF File', '',
         'TOF File (*.tof *.TOF);;All files (*)')[0]
     if filename:
         self.widget.LoadTofFile(filename)
         self.add_to_flist(filename, 'tof')
Example #3
0
    def on_loadTableButton_clicked(self):
        try:
            filename = QFileDialog.getOpenFileName(
                self,
                'Open table',
                osp.expanduser('~') if self.last_save_location is None \
                    else self.last_save_location,
                'Table Files (*.txt *.csv)')[0]

            if not filename:
                return

            headers_from_file, data = import_table_from_csv(filename)

            if not set(headers_from_file).issubset(set(self.columns_in_order)):
                raise AttributeError('incorrect headers in file')
            # Clear existing table before populating from file
            self.on_clearTableButton_clicked()
            self._fill_table(headers_from_file, data)

            for optional in set(headers_from_file).intersection(
                    set(self.optional_columns.keys())):
                self.optional_columns[optional][1].setChecked(True)
        except Exception as error:
            self.showError(f'Could not load {filename}:  {error}')
Example #4
0
 def selectQSS(self):
     stylefile = QFileDialog.getOpenFileName(self,
                                             filter="Qt Stylesheet Files ("
                                             "*.qss)")[0]
     if stylefile:
         self.stylefile = stylefile
         self.setQSS(self.stylefile)
Example #5
0
    def loadFile(self):
        # allows a user to specify the setup file to be parsed
        setupFile = QFileDialog.getOpenFileName(self, 'Open Python script',
                                                path.expanduser('.'),
                                                'Python Files (*.py)')[0]

        if setupFile:
            self.readSetupFile(setupFile)
Example #6
0
 def selectInputFile(self, ctl, text='Choose an input file'):
     previous = ctl.text()
     if previous:
         startdir = path.dirname(previous)
     else:
         startdir = '.'
     fn = QFileDialog.getOpenFileName(self, text, startdir,
                                      'All files (*)')[0]
     if fn:
         ctl.setText(fn)
Example #7
0
 def on_actionOpen_triggered(self):
     if self.currentEditor is not None and self.filenames[self.currentEditor]:
         initialdir = path.dirname(self.filenames[self.currentEditor])
     else:
         initialdir = self.client.eval('session.experiment.scriptpath', '')
     fn = QFileDialog.getOpenFileName(self, 'Open script', initialdir,
                                      'Script files (*.py *.txt)')[0]
     if not fn:
         return
     self.openFile(fn)
     self.addToRecentf(fn)
Example #8
0
 def on_openFileBtn_clicked(self):
     initialdir = self.client.eval('session.experiment.scriptpath', '')
     fn = QFileDialog.getOpenFileName(self, 'Open sample file', initialdir,
                                      'Sample files (*.py)')[0]
     if not fn:
         return
     try:
         self.configs = parse_sampleconf(fn)
     except Exception as err:
         self.showError('Could not read file: %s\n\n'
                        'Are you sure this is a sample file?' % err)
     else:
         self.fileGroup.setEnabled(False)
         self.sampleGroup.setEnabled(True)
         newitem = None
         for config in self.configs:
             newitem = QListWidgetItem(config['name'], self.list)
         # select the last item
         if newitem:
             self.list.setCurrentItem(newitem)
         self.on_list_itemClicked(newitem)
         self.filename = fn
Example #9
0
 def on_sampleFileBtn_toggled(self, on):
     if not on:
         return
     if not self._init_samplefile:
         initialdir = self.client.eval('session.experiment.scriptpath', '')
         fn = QFileDialog.getOpenFileName(self, 'Open sample file',
                                          initialdir, 'Sample files (*.py)')[0]
         if not fn:
             self.currentSamplesBtn.setChecked(True)
             return
     else:
         fn = self.samplefile
     try:
         configs = parse_sampleconf(fn)
     except Exception as err:
         self.showError('Could not read file: %s\n\n'
                        'Are you sure this is a sample file?' % err)
         self.currentSamplesBtn.setChecked(True)
         return
     self.samplefile = fn
     self.sampleFileLbl.setText(fn)
     self.sampleFileBtn.setChecked(True)
     self._reinit(dict(enumerate(configs)))
Example #10
0
 def selectFileName(self):
     fn, _ = QFileDialog.getOpenFileName(self, 'Load data points')
     if fn:
         self.fileName.setText(fn)
         self.fileName.editingFinished.emit()