Loading misc/test_interp.py 0 → 100755 +47 −0 Original line number Diff line number Diff line #!/usr/bin/env python import sys import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import LinearNDInterpolator from scipy.interpolate import CloughTocher2DInterpolator pt = np.loadtxt(sys.argv[1], usecols=(0,1,2)) proj3d = False if len(sys.argv)>2: proj3d = sys.argv[2] print(pt) #Interpolator = CloughTocher2DInterpolator Interpolator = LinearNDInterpolator x = pt[:,1] y = pt[:,0] z = pt[:,2] X = np.linspace(-2, 40) Y = np.linspace( 0, 90) X, Y = np.meshgrid(X, Y) # 2D grid for interpolation interp = Interpolator(list(zip(x,y)), z) Z = interp(X, Y) fig = plt.figure() if proj3d: ax = fig.add_subplot(projection='3d') ax.plot_wireframe(X, Y, Z, label='Z') ax.scatter(x, y, z, 'o', color='k', s=48, label='data') else: plt.pcolormesh(X, Y, Z, shading='auto') plt.plot(x, y, "ro", ms=3, label="input point") plt.legend() plt.colorbar() #plt.axis("equal") plt.show() pysen/ui/FileMonMainWindow.py +27 −32 Original line number Diff line number Diff line Loading @@ -4,20 +4,14 @@ Main GUI window module. import os import platform from PyQt5.QtCore import Qt, QTimer, QT_VERSION_STR, PYQT_VERSION_STR from PyQt5.QtGui import QFont, QColor from PyQt5.QtWidgets import (qApp, QMainWindow, QFrame, QLabel, QWidget, QSplitter, QGridLayout, QScrollArea, QSizePolicy, QPushButton, QMessageBox, QFontDialog) from qtpy import QtWidgets, QtCore, QtGui from .ui_FileMonMainWindow import Ui_FileMonMainWindow as Ui_MainWindow TEXT_FONT = QFont("Monospace", 10) if platform.system()=='Darwin': TEXT_FONT = QFont("Monaco", 10) TEXT_BACK_COLOR_ENABLED = QColor( 80, 255, 20) TEXT_BACK_COLOR_DISABLED = QColor(170, 170, 170) TEXT_FONT = QtGui.QFont("Monospace", 10) if platform.system()!='Darwin' else QtGui.QFont("Monaco", 10) TEXT_BACK_COLOR_ENABLED = QtGui.QColor( 80, 255, 20) TEXT_BACK_COLOR_DISABLED = QtGui.QColor(170, 170, 170) def setBackgroundColor(textLabel, color): "set background color of a text label" Loading @@ -27,7 +21,7 @@ def setBackgroundColor(textLabel, color): textLabel.setPalette(palette) class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Main for viewing and deleting available groups. """ Loading @@ -43,19 +37,19 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.menubar.setNativeMenuBar(False) # File menu actions self.actionExit.triggered.connect(qApp.quit) self.actionExit.triggered.connect(QtWidgets.qApp.quit) self.actionFontSelection.triggered.connect(self.font_choice) # Help menu actions self.actionAbout.triggered.connect(self.about_box) splitter = QSplitter(Qt.Horizontal) splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) for filename in self.filenames: tb = self.make_view(filename, splitter) self.textboxes[filename] = tb self.setCentralWidget(splitter) timer = QTimer() timer = QtCore.QTimer() timer.setInterval(interval) timer.timeout.connect(self.load_files) Loading @@ -64,40 +58,41 @@ class MainWindow(QMainWindow, Ui_MainWindow): def make_view(self, filename, splitter): "make view" widget = QWidget(splitter) gridLayout = QGridLayout(widget) widget = QtWidgets.QWidget(splitter) gridLayout = QtWidgets.QGridLayout(widget) gridLayout.setContentsMargins(0,0,0,0) label = QLabel(widget) label = QtWidgets.QLabel(widget) label.setIndent(10) short_name = os.path.basename(filename) label.setText(short_name) gridLayout.addWidget(label, 1, 0, 1, 2) textLabel = QLabel() textLabel = QtWidgets.QLabel() textLabel.setParent(widget) textLabel.setFont(TEXT_FONT) textLabel.setTextInteractionFlags(Qt.TextSelectableByKeyboard|Qt.TextSelectableByMouse) textLabel.setAlignment(Qt.AlignTop) textLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard| QtCore.Qt.TextSelectableByMouse) textLabel.setAlignment(QtCore.Qt.AlignTop) setBackgroundColor(textLabel, TEXT_BACK_COLOR_ENABLED) scrollArea = QScrollArea() scrollArea = QtWidgets.QScrollArea() scrollArea.setWidget(textLabel) scrollArea.setAlignment(Qt.AlignLeft) scrollArea.setAlignment(QtCore.Qt.AlignLeft) scrollArea.setWidgetResizable(True) gridLayout.addWidget(scrollArea, 0, 0, 1, 2) pushButton = QPushButton(widget) pushButton = QtWidgets.QPushButton(widget) pushButton.setCheckable(True) pushButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) pushButton.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) pushButton.setText("Pause") gridLayout.addWidget(pushButton, 2, 1, 1, 1) pushButton.clicked.connect(lambda: self.pause_file(filename, pushButton)) label = QLabel(widget) label.setFrameStyle(QFrame.Panel | QFrame.Sunken) label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) label = QtWidgets.QLabel(widget) label.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken) label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) gridLayout.addWidget(label, 2, 0, 1, 1) splitter.addWidget(widget) Loading @@ -105,7 +100,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): def font_choice(self): "selet display font" font, valid = QFontDialog.getFont() font, valid = QtWidgets.QFontDialog.getFont() if valid: for tb in self.textboxes.values(): tb.setFont(font) Loading @@ -115,11 +110,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): msg = """<center><font size=+1><b>Basic User Browser</b></font><br> for Pycon 2011</center><br><br> An application to demonstrate GUI programming with Python and Qt.<br><br> Uses Python v%s with Qt v%s and PyQt v%s on %s. Uses Python v%s with PyQt v%s on %s. """ QMessageBox.about(self.parent(), 'PyQt I Tutorial', msg % (platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platform.system())) QtWidgets.QMessageBox.about(self.parent(), 'PyQt I Tutorial', msg % (platform.python_version(), QtCore.PYQT_VERSION_STR, platform.system())) self.activateWindow() #def closeEvent(self, event): Loading pysen/ui/NSEMainWindow.py +7 −8 Original line number Diff line number Diff line """ Main GUI window module. """ #pylint: disable=invalid-name from PyQt5.QtWidgets import qApp, QMainWindow, QMessageBox, QVBoxLayout, QFileDialog from matplotlib.backends.backend_qt5agg import FigureCanvas #pylint: disable=no-name-in-module from qtpy import QtWidgets from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module from matplotlib.figure import Figure from .jupyter_console import EmbeddedJupyterConsole from .ui_NSEMainWindow import Ui_NSEMainWindow as Ui_MainWindow from ..plot.nseplotlib import plot as default_plot class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Main for viewing and deleting available groups. """ Loading Loading @@ -38,13 +37,13 @@ class MainWindow(QMainWindow, Ui_MainWindow): # self.console = EmbeddedJupyterConsole(figure=self.fig, plot=default_plot) self.kernel_manager = self.console.kernel_manager self.tab_Shell.layout = QVBoxLayout(self.tab_Shell) self.tab_Shell.layout = QtWidgets.QVBoxLayout(self.tab_Shell) self.tab_Shell.layout.addWidget(self.console) def file_open(self): "file/open action" file_filter = "All Files (*);; NeXus Files (*.nxs.h5);;Echo Files (*.echo);;Misc Files (*.dat)" file_dialog = QFileDialog() file_dialog = QtWidgets.QFileDialog() file_dialog.setWindowTitle("Open File") #file_dialog.setFileMode(QFileDialog.FileMode.ExistingFile) #file_dialog.setViewMode(QFileDialog.ViewMode.Detail) Loading @@ -55,12 +54,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): def file_exit(self): "file/exit action" qApp.quit() QtWidgets.qApp.quit() def help_about(self): "help/about action" msg ="""To Be Written""" QMessageBox.about(self.parent(), self.windowTitle(), msg) QtWidgets.QMessageBox.about(self.parent(), self.windowTitle(), msg) self.activateWindow() def plot_file(self, filename): Loading pysen/ui/QTauMainWindow.py +6 −6 Original line number Diff line number Diff line Loading @@ -5,10 +5,10 @@ Main GUI window module. #import time #import numpy as np from PyQt5.QtWidgets import qApp, QMainWindow, QMessageBox from matplotlib.backends.backend_qt5agg import FigureCanvas #pylint: disable=no-name-in-module from matplotlib.figure import Figure from qtpy import QtWidgets from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module from matplotlib.figure import Figure from ..config import coverage from ..plot.qplot import plot_coverage Loading @@ -17,7 +17,7 @@ from ..plot.qplot import plot_coverage #pylint: disable=import-error from .ui_QTauMainWindow import Ui_QTauMainWindow as Ui_MainWindow class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Main for viewing and deleting available groups. """ Loading @@ -40,7 +40,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): # # File menu actions self.actionExit.triggered.connect(qApp.quit) self.actionExit.triggered.connect(QtWidgets.qApp.quit) # self.actionTauScaleLog.toggled.connect(self._update_canvas) self.actionQScaleLog.toggled.connect(self._update_canvas) Loading Loading @@ -69,5 +69,5 @@ class MainWindow(QMainWindow, Ui_MainWindow): def about_box(self): "help about" msg = """To Be Written""" QMessageBox.about(self.parent(), self.windowTitle(), msg) QtWidgets.QMessageBox.about(self.parent(), self.windowTitle(), msg) self.activateWindow() pysen/ui/SimpleEchoSimulator.py +19 −24 Original line number Diff line number Diff line """ Main GUI window module. """ #pylint: disable=invalid-name import numpy as np try: from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import qApp, QMainWindow, QMessageBox #,QVBoxLayout #, QTabWidget, QWidget) from PyQt5.QtGui import QDoubleValidator from matplotlib.backends.backend_qt5agg import FigureCanvas except ImportError: pass from matplotlib.figure import Figure # from qtpy import QtWidgets, QtCore, QtGui from numpy import pi, exp, log10 # from matplotlib.figure import Figure from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module from ..config import wavelength_bandwidth from ..constants import ANGSTROM, OMEGA_N from ..echo.fit import flux_weighted_eshape as echo_shape # from .ui_SimpleEchoSimulator import Ui_SimpleEchoSimMainWindow as Ui_MainWindow MICRO=1e-6 Loading @@ -30,13 +25,14 @@ def sqt(t, coh, tcoh, inc, tinc, bgr=0): "S(Q,t)/S(Q,0)" return coh*f_exp(t,tcoh)-1/3*(inc*f_exp(t,tinc)+bgr) class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """Main for viewing and deleting available groups.""" #pylint: disable=too-many-instance-attributes def __init__(self, parent=None, **kwargs): """init MainWindow""" super().__init__(parent) self.setupUi(self) self.menuBar.setNativeMenuBar(False) #self.menuBar.setCornerWidget(self.menuHelp, Qt.TopRightCorner) # Loading Loading @@ -67,16 +63,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): #self.dblSpinBoxTinc.valueChanged.connect(self.handleSpinBoxTauInc) #self.dblSpinBoxTecho.valueChanged.connect(self.handleSpinBoxTauEcho) # self.inpTauCoh.setValidator(QDoubleValidator(1e-6, 1e6, 3)) self.inpTauInc.setValidator(QDoubleValidator(1e-6, 1e6, 3)) self.inpTauEcho.setValidator(QDoubleValidator(1e-3, 1e3, 3)) self.inpTauCoh.setValidator(QtGui.QDoubleValidator(1e-6, 1e6, 3)) self.inpTauInc.setValidator(QtGui.QDoubleValidator(1e-6, 1e6, 3)) self.inpTauEcho.setValidator(QtGui.QDoubleValidator(1e-3, 1e3, 3)) # self.inpTauCoh.returnPressed.connect(self.handleInpTauCoh) self.inpTauInc.returnPressed.connect(self.handleInpTauInc) self.inpTauEcho.returnPressed.connect(self.handleInpTauEcho) # File menu actions self.actionExit.triggered.connect(qApp.quit) self.actionExit.triggered.connect(QtWidgets.qApp.quit) self.actionReset.triggered.connect(self.reset) self.actionAbout.triggered.connect(self.about_box) Loading @@ -98,39 +94,38 @@ class MainWindow(QMainWindow, Ui_MainWindow): label.setText(f"{value*1e6:8.1f} fs") # Intensities @pyqtSlot(float) @QtCore.Slot(float) def handleSpinBoxCoh(self, _value): "Icoh handler" self._update_canvas() @pyqtSlot(float) @QtCore.Slot(float) def handleSpinBoxInc(self, _value): "Iinc handler" self._update_canvas() @pyqtSlot(float) @QtCore.Slot(float) def handleSpinBoxBgr(self, _value): "Ibgr handler" self._update_canvas() # Tau sliders @pyqtSlot(int) @QtCore.Slot(int) def handleSliderTauCoh(self, value): "tau coh slider handler" tau = 10**(value/1000.0) self.inpTauCoh.setText(f"{tau:.4g}") self._update_canvas() @pyqtSlot(int) @QtCore.Slot(int) def handleSliderTauInc(self, value): "tau inc slider handler" tau = 10**(value/1000.0) self.inpTauInc.setText(f"{tau:.4g}") self._update_canvas() @pyqtSlot(int) @QtCore.Slot(int) def handleSliderTauEcho(self, value): "tau echo slider handler" tau = 10**(value/1000.0) Loading Loading @@ -291,5 +286,5 @@ class MainWindow(QMainWindow, Ui_MainWindow): def about_box(self): "help about" msg = """To Be Written""" QMessageBox.about(self.parent(), self.windowTitle(), msg) QtWidgets.QMessageBox.about(self.parent(), self.windowTitle(), msg) self.activateWindow() Loading
misc/test_interp.py 0 → 100755 +47 −0 Original line number Diff line number Diff line #!/usr/bin/env python import sys import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import LinearNDInterpolator from scipy.interpolate import CloughTocher2DInterpolator pt = np.loadtxt(sys.argv[1], usecols=(0,1,2)) proj3d = False if len(sys.argv)>2: proj3d = sys.argv[2] print(pt) #Interpolator = CloughTocher2DInterpolator Interpolator = LinearNDInterpolator x = pt[:,1] y = pt[:,0] z = pt[:,2] X = np.linspace(-2, 40) Y = np.linspace( 0, 90) X, Y = np.meshgrid(X, Y) # 2D grid for interpolation interp = Interpolator(list(zip(x,y)), z) Z = interp(X, Y) fig = plt.figure() if proj3d: ax = fig.add_subplot(projection='3d') ax.plot_wireframe(X, Y, Z, label='Z') ax.scatter(x, y, z, 'o', color='k', s=48, label='data') else: plt.pcolormesh(X, Y, Z, shading='auto') plt.plot(x, y, "ro", ms=3, label="input point") plt.legend() plt.colorbar() #plt.axis("equal") plt.show()
pysen/ui/FileMonMainWindow.py +27 −32 Original line number Diff line number Diff line Loading @@ -4,20 +4,14 @@ Main GUI window module. import os import platform from PyQt5.QtCore import Qt, QTimer, QT_VERSION_STR, PYQT_VERSION_STR from PyQt5.QtGui import QFont, QColor from PyQt5.QtWidgets import (qApp, QMainWindow, QFrame, QLabel, QWidget, QSplitter, QGridLayout, QScrollArea, QSizePolicy, QPushButton, QMessageBox, QFontDialog) from qtpy import QtWidgets, QtCore, QtGui from .ui_FileMonMainWindow import Ui_FileMonMainWindow as Ui_MainWindow TEXT_FONT = QFont("Monospace", 10) if platform.system()=='Darwin': TEXT_FONT = QFont("Monaco", 10) TEXT_BACK_COLOR_ENABLED = QColor( 80, 255, 20) TEXT_BACK_COLOR_DISABLED = QColor(170, 170, 170) TEXT_FONT = QtGui.QFont("Monospace", 10) if platform.system()!='Darwin' else QtGui.QFont("Monaco", 10) TEXT_BACK_COLOR_ENABLED = QtGui.QColor( 80, 255, 20) TEXT_BACK_COLOR_DISABLED = QtGui.QColor(170, 170, 170) def setBackgroundColor(textLabel, color): "set background color of a text label" Loading @@ -27,7 +21,7 @@ def setBackgroundColor(textLabel, color): textLabel.setPalette(palette) class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Main for viewing and deleting available groups. """ Loading @@ -43,19 +37,19 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.menubar.setNativeMenuBar(False) # File menu actions self.actionExit.triggered.connect(qApp.quit) self.actionExit.triggered.connect(QtWidgets.qApp.quit) self.actionFontSelection.triggered.connect(self.font_choice) # Help menu actions self.actionAbout.triggered.connect(self.about_box) splitter = QSplitter(Qt.Horizontal) splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) for filename in self.filenames: tb = self.make_view(filename, splitter) self.textboxes[filename] = tb self.setCentralWidget(splitter) timer = QTimer() timer = QtCore.QTimer() timer.setInterval(interval) timer.timeout.connect(self.load_files) Loading @@ -64,40 +58,41 @@ class MainWindow(QMainWindow, Ui_MainWindow): def make_view(self, filename, splitter): "make view" widget = QWidget(splitter) gridLayout = QGridLayout(widget) widget = QtWidgets.QWidget(splitter) gridLayout = QtWidgets.QGridLayout(widget) gridLayout.setContentsMargins(0,0,0,0) label = QLabel(widget) label = QtWidgets.QLabel(widget) label.setIndent(10) short_name = os.path.basename(filename) label.setText(short_name) gridLayout.addWidget(label, 1, 0, 1, 2) textLabel = QLabel() textLabel = QtWidgets.QLabel() textLabel.setParent(widget) textLabel.setFont(TEXT_FONT) textLabel.setTextInteractionFlags(Qt.TextSelectableByKeyboard|Qt.TextSelectableByMouse) textLabel.setAlignment(Qt.AlignTop) textLabel.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard| QtCore.Qt.TextSelectableByMouse) textLabel.setAlignment(QtCore.Qt.AlignTop) setBackgroundColor(textLabel, TEXT_BACK_COLOR_ENABLED) scrollArea = QScrollArea() scrollArea = QtWidgets.QScrollArea() scrollArea.setWidget(textLabel) scrollArea.setAlignment(Qt.AlignLeft) scrollArea.setAlignment(QtCore.Qt.AlignLeft) scrollArea.setWidgetResizable(True) gridLayout.addWidget(scrollArea, 0, 0, 1, 2) pushButton = QPushButton(widget) pushButton = QtWidgets.QPushButton(widget) pushButton.setCheckable(True) pushButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) pushButton.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) pushButton.setText("Pause") gridLayout.addWidget(pushButton, 2, 1, 1, 1) pushButton.clicked.connect(lambda: self.pause_file(filename, pushButton)) label = QLabel(widget) label.setFrameStyle(QFrame.Panel | QFrame.Sunken) label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) label = QtWidgets.QLabel(widget) label.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken) label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) gridLayout.addWidget(label, 2, 0, 1, 1) splitter.addWidget(widget) Loading @@ -105,7 +100,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): def font_choice(self): "selet display font" font, valid = QFontDialog.getFont() font, valid = QtWidgets.QFontDialog.getFont() if valid: for tb in self.textboxes.values(): tb.setFont(font) Loading @@ -115,11 +110,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): msg = """<center><font size=+1><b>Basic User Browser</b></font><br> for Pycon 2011</center><br><br> An application to demonstrate GUI programming with Python and Qt.<br><br> Uses Python v%s with Qt v%s and PyQt v%s on %s. Uses Python v%s with PyQt v%s on %s. """ QMessageBox.about(self.parent(), 'PyQt I Tutorial', msg % (platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platform.system())) QtWidgets.QMessageBox.about(self.parent(), 'PyQt I Tutorial', msg % (platform.python_version(), QtCore.PYQT_VERSION_STR, platform.system())) self.activateWindow() #def closeEvent(self, event): Loading
pysen/ui/NSEMainWindow.py +7 −8 Original line number Diff line number Diff line """ Main GUI window module. """ #pylint: disable=invalid-name from PyQt5.QtWidgets import qApp, QMainWindow, QMessageBox, QVBoxLayout, QFileDialog from matplotlib.backends.backend_qt5agg import FigureCanvas #pylint: disable=no-name-in-module from qtpy import QtWidgets from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module from matplotlib.figure import Figure from .jupyter_console import EmbeddedJupyterConsole from .ui_NSEMainWindow import Ui_NSEMainWindow as Ui_MainWindow from ..plot.nseplotlib import plot as default_plot class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Main for viewing and deleting available groups. """ Loading Loading @@ -38,13 +37,13 @@ class MainWindow(QMainWindow, Ui_MainWindow): # self.console = EmbeddedJupyterConsole(figure=self.fig, plot=default_plot) self.kernel_manager = self.console.kernel_manager self.tab_Shell.layout = QVBoxLayout(self.tab_Shell) self.tab_Shell.layout = QtWidgets.QVBoxLayout(self.tab_Shell) self.tab_Shell.layout.addWidget(self.console) def file_open(self): "file/open action" file_filter = "All Files (*);; NeXus Files (*.nxs.h5);;Echo Files (*.echo);;Misc Files (*.dat)" file_dialog = QFileDialog() file_dialog = QtWidgets.QFileDialog() file_dialog.setWindowTitle("Open File") #file_dialog.setFileMode(QFileDialog.FileMode.ExistingFile) #file_dialog.setViewMode(QFileDialog.ViewMode.Detail) Loading @@ -55,12 +54,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): def file_exit(self): "file/exit action" qApp.quit() QtWidgets.qApp.quit() def help_about(self): "help/about action" msg ="""To Be Written""" QMessageBox.about(self.parent(), self.windowTitle(), msg) QtWidgets.QMessageBox.about(self.parent(), self.windowTitle(), msg) self.activateWindow() def plot_file(self, filename): Loading
pysen/ui/QTauMainWindow.py +6 −6 Original line number Diff line number Diff line Loading @@ -5,10 +5,10 @@ Main GUI window module. #import time #import numpy as np from PyQt5.QtWidgets import qApp, QMainWindow, QMessageBox from matplotlib.backends.backend_qt5agg import FigureCanvas #pylint: disable=no-name-in-module from matplotlib.figure import Figure from qtpy import QtWidgets from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module from matplotlib.figure import Figure from ..config import coverage from ..plot.qplot import plot_coverage Loading @@ -17,7 +17,7 @@ from ..plot.qplot import plot_coverage #pylint: disable=import-error from .ui_QTauMainWindow import Ui_QTauMainWindow as Ui_MainWindow class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Main for viewing and deleting available groups. """ Loading @@ -40,7 +40,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): # # File menu actions self.actionExit.triggered.connect(qApp.quit) self.actionExit.triggered.connect(QtWidgets.qApp.quit) # self.actionTauScaleLog.toggled.connect(self._update_canvas) self.actionQScaleLog.toggled.connect(self._update_canvas) Loading Loading @@ -69,5 +69,5 @@ class MainWindow(QMainWindow, Ui_MainWindow): def about_box(self): "help about" msg = """To Be Written""" QMessageBox.about(self.parent(), self.windowTitle(), msg) QtWidgets.QMessageBox.about(self.parent(), self.windowTitle(), msg) self.activateWindow()
pysen/ui/SimpleEchoSimulator.py +19 −24 Original line number Diff line number Diff line """ Main GUI window module. """ #pylint: disable=invalid-name import numpy as np try: from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import qApp, QMainWindow, QMessageBox #,QVBoxLayout #, QTabWidget, QWidget) from PyQt5.QtGui import QDoubleValidator from matplotlib.backends.backend_qt5agg import FigureCanvas except ImportError: pass from matplotlib.figure import Figure # from qtpy import QtWidgets, QtCore, QtGui from numpy import pi, exp, log10 # from matplotlib.figure import Figure from matplotlib.backends.backend_qtagg import FigureCanvas #pylint: disable=no-name-in-module from ..config import wavelength_bandwidth from ..constants import ANGSTROM, OMEGA_N from ..echo.fit import flux_weighted_eshape as echo_shape # from .ui_SimpleEchoSimulator import Ui_SimpleEchoSimMainWindow as Ui_MainWindow MICRO=1e-6 Loading @@ -30,13 +25,14 @@ def sqt(t, coh, tcoh, inc, tinc, bgr=0): "S(Q,t)/S(Q,0)" return coh*f_exp(t,tcoh)-1/3*(inc*f_exp(t,tinc)+bgr) class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """Main for viewing and deleting available groups.""" #pylint: disable=too-many-instance-attributes def __init__(self, parent=None, **kwargs): """init MainWindow""" super().__init__(parent) self.setupUi(self) self.menuBar.setNativeMenuBar(False) #self.menuBar.setCornerWidget(self.menuHelp, Qt.TopRightCorner) # Loading Loading @@ -67,16 +63,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): #self.dblSpinBoxTinc.valueChanged.connect(self.handleSpinBoxTauInc) #self.dblSpinBoxTecho.valueChanged.connect(self.handleSpinBoxTauEcho) # self.inpTauCoh.setValidator(QDoubleValidator(1e-6, 1e6, 3)) self.inpTauInc.setValidator(QDoubleValidator(1e-6, 1e6, 3)) self.inpTauEcho.setValidator(QDoubleValidator(1e-3, 1e3, 3)) self.inpTauCoh.setValidator(QtGui.QDoubleValidator(1e-6, 1e6, 3)) self.inpTauInc.setValidator(QtGui.QDoubleValidator(1e-6, 1e6, 3)) self.inpTauEcho.setValidator(QtGui.QDoubleValidator(1e-3, 1e3, 3)) # self.inpTauCoh.returnPressed.connect(self.handleInpTauCoh) self.inpTauInc.returnPressed.connect(self.handleInpTauInc) self.inpTauEcho.returnPressed.connect(self.handleInpTauEcho) # File menu actions self.actionExit.triggered.connect(qApp.quit) self.actionExit.triggered.connect(QtWidgets.qApp.quit) self.actionReset.triggered.connect(self.reset) self.actionAbout.triggered.connect(self.about_box) Loading @@ -98,39 +94,38 @@ class MainWindow(QMainWindow, Ui_MainWindow): label.setText(f"{value*1e6:8.1f} fs") # Intensities @pyqtSlot(float) @QtCore.Slot(float) def handleSpinBoxCoh(self, _value): "Icoh handler" self._update_canvas() @pyqtSlot(float) @QtCore.Slot(float) def handleSpinBoxInc(self, _value): "Iinc handler" self._update_canvas() @pyqtSlot(float) @QtCore.Slot(float) def handleSpinBoxBgr(self, _value): "Ibgr handler" self._update_canvas() # Tau sliders @pyqtSlot(int) @QtCore.Slot(int) def handleSliderTauCoh(self, value): "tau coh slider handler" tau = 10**(value/1000.0) self.inpTauCoh.setText(f"{tau:.4g}") self._update_canvas() @pyqtSlot(int) @QtCore.Slot(int) def handleSliderTauInc(self, value): "tau inc slider handler" tau = 10**(value/1000.0) self.inpTauInc.setText(f"{tau:.4g}") self._update_canvas() @pyqtSlot(int) @QtCore.Slot(int) def handleSliderTauEcho(self, value): "tau echo slider handler" tau = 10**(value/1000.0) Loading Loading @@ -291,5 +286,5 @@ class MainWindow(QMainWindow, Ui_MainWindow): def about_box(self): "help about" msg = """To Be Written""" QMessageBox.about(self.parent(), self.windowTitle(), msg) QtWidgets.QMessageBox.about(self.parent(), self.windowTitle(), msg) self.activateWindow()