def open_browser(self, directory): bwin = BrowseWindow(self) bwin.show() QApplication.processEvents() try: bwin.set_directory(directory) except OSError: pass bwin.activateWindow()
def readData(self): """ This function will read data from files indicated by folder and Numors """ numors = self.ui.txtNumors.text() self.canvas.axes.text(0.5, 0.5, 'Please wait, loading all data...', horizontalalignment='center') self.canvas.draw() QApplication.processEvents() self.reader = qr.QReader(self.dir, numors) self.canvas.axes.clear() self.canvas.draw()
def readPoints(self): """ It will find points in read scan files which has hkle values These is then converted to orientation vector basis and calculated distance from it. Only inplane points are processed. """ self.readVectors() self.canvas.axes.text(0.5, 0.5, 'Please wait, parsing read data...', horizontalalignment='center') self.canvas.draw() QApplication.processEvents() self.pts = self.reader.get_points(self.v1, self.v2) print("Datafiles read:", len(self.pts)) self.canvas.axes.clear() self.canvas.draw() self.showPoints()
def do_fit(self): if self.picking: QMessageBox.information(self, 'Fitting', 'Please finish the picking operation first.') return self.update_from_controls() self.statusLabel.setText('Working...') self.statusLabel.repaint() QApplication.processEvents() try: res = self.model.fit(self.data, **self.fit_kws) except Exception as e: self.logger.exception('Error during fit') self.statusLabel.setText('Error during fit: %s' % e) return self.on_modelFitted(self.item, res) self.replotRequest.emit(True) session.set_dirty()
def set_directory(self, root): self.setWindowTitle('ufit browser - %s' % root) self.canvas.axes.text(0.5, 0.5, 'Please wait, loading all data...', horizontalalignment='center') self.canvas.draw() QApplication.processEvents() self.rootdir = root files = os.listdir(root) self.dataList.clear() for fn in sorted(files): fn = path.join(root, fn) if not path.isfile(fn): continue try: t, n = extract_template(fn) self.loader.template = t fixed_yaxis = self.yAxisEdit.text() yaxis = fixed_yaxis if ( fixed_yaxis and self.useYAxis.isChecked()) else 'auto' res = self.loader.load(n, 'auto', yaxis, 'auto', 'auto', -1) except Exception as e: self.logger.warning('While loading %r: %s' % (fn, e)) else: if self.useMonScale.isChecked(): const = int(self.monScaleEdit.text()) # XXX check res.rescale(const) if self.useFmtString.isChecked(): try: scanLabel = self.fmtStringEdit.text().format( n, FormatWrapper(res)) except Exception: scanLabel = '%s (%s) - %s | %s' % ( n, res.xcol, res.title, ', '.join(res.environment)) else: scanLabel = '%s (%s) - %s | %s' % ( n, res.xcol, res.title, ', '.join(res.environment)) self._data[n] = res QListWidgetItem(scanLabel, self.dataList, n) self.canvas.axes.clear() self.canvas.draw()
ax.yaxis.label.set_fontsize(toset[1]) for t in ax.xaxis.get_major_ticks(): t.label.set_fontsize(toset[2]) for t in ax.yaxis.get_major_ticks(): t.label.set_fontsize(toset[2]) if (ax.legend_): for t in ax.legend_.texts: t.set_fontsize(toset[1]) self.canvas.plotter.draw() def addBZ(self): """ Experimental: add brilluin zone. Only Body centered tetragonal now supported. """ # check by vectors self.readVectors() myplane = np.cross(self.v1, self.v2) # TODO: generate gamma point dynamically gpts = np.array([[0, 0], [0, 2], [1, 1], [2, 0], [2, 2]]) # TODO: read lattice parameters from file bzc = bp.BZCreator(gpts, a = 4.33148, c = 10.83387, plane = myplane) bzc.doPlot(self.canvas.plotter.axes) self.canvas.plotter.draw() # Run the gui if not imported if __name__ == "__main__": app = QApplication(sys.argv) win = ReciprocalViewer() sys.exit(app.exec_())
def start(model, data, fit=True, **fit_kws): app = QApplication([]) win = FitterMain(model, data, fit, fit_kws) win.show() app.exec_() return win.fitter.last_result
def main(): app = QApplication([]) app.setOrganizationName('ufit') app.setApplicationName('gui') pixmap = QPixmap(':/splash.png') splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.showMessage(u'Loading...' + u'\xa0' * 10 + '\n\n', Qt.AlignRight | Qt.AlignBottom) splash.show() time.sleep(0.1) with SettingGroup('main') as settings: if settings.value('current_version', '') != __version__: settings.setValue('current_version', __version__) # Execute here the actions to be performed only once after # each update (there is nothing there for now, but it could # be useful some day...) logger.info('Upgrade to version %s finished' % __version__) app.processEvents() def log_unhandled(*exc_info): logger.error('Unhandled exception in Qt callback', exc_info=exc_info) sys.excepthook = log_unhandled t1 = time.time() logger.info('Startup: import finished (%.3f s), starting GUI...' % (t1 - t0)) mainwindow = UFitMain() parser = optparse.OptionParser(usage='''\ Usage: %prog [-b directory] [.ufit file | data file] ''') parser.add_option('-b', '--browse', action='store', metavar='DIR', help='open browse window in specified directory') opts, args = parser.parse_args() if len(args) >= 1: datafile = path.abspath(args[0]) if path.isdir(datafile): # directory given, treat it as -b argument (browse) opts.browse = datafile elif datafile.endswith('.ufit'): try: mainwindow.filename = datafile mainwindow.load_session(datafile) except Exception as err: QMessageBox.warning(mainwindow, 'Error', 'Loading failed: %s' % err) mainwindow.filename = None else: dtempl, numor = extract_template(datafile) mainwindow.dloader.set_template(dtempl, numor, silent=False) mainwindow.show() if opts.browse: mainwindow.dloader.open_browser(opts.browse) t2 = time.time() logger.info('Startup: loading finished (%.3f s), main window opened' % (t2 - t1)) splash.deleteLater() app.exec_()
def start(): app = QApplication([]) win = DataLoaderMain() win.show() app.exec_() return win.dloader.last_data