Skip to content
Snippets Groups Projects
Commit 98ae80ea authored by WHITFIELDRE email's avatar WHITFIELDRE email
Browse files

Move TofConverter to qtpy and add to workbench

parent aa460346
No related branches found
No related tags found
No related merge requests found
......@@ -19,5 +19,5 @@ INSTALLDIR=$(dirname $INSTALLDIR) # root install directory
# Launch
LD_PRELOAD=${LOCAL_PRELOAD} TCMALLOC_RELEASE_RATE=${TCM_RELEASE} \
TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD=${TCM_REPORT} \
TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD=${TCM_REPORT} QT_API=pyqt \
@WRAPPER_PREFIX@$VGLRUN $GDB $INSTALLDIR/bin/@MANTIDPLOT_EXEC@ $*@WRAPPER_POSTFIX@ || @PYTHON_EXECUTABLE@ @SCRIPTSDIR@/@ERROR_CMD@
......@@ -261,7 +261,8 @@ class MainWindow(QMainWindow):
# list of custom interfaces that have been made qt4/qt5 compatible
# TODO need to make *anything* compatible
GUI_WHITELIST = ['FilterEvents.py']
GUI_WHITELIST = ['FilterEvents.py',
'TofConverter.py']
# detect the python interfaces
interfaces = {}
......
......@@ -7,19 +7,11 @@
#pylint: disable=invalid-name
from __future__ import (absolute_import, division, print_function)
from TofConverter import converterGUI
from PyQt4 import QtGui
import sys
from gui_helper import get_qapplication
app, within_mantid = get_qapplication()
def qapp():
if QtGui.QApplication.instance():
_app = QtGui.QApplication.instance()
else:
_app = QtGui.QApplication(sys.argv)
return _app
app = qapp()
reducer = converterGUI.MainWindow()#the main ui class in this file is called MainWindow
reducer.show()
app.exec_()
if not within_mantid:
app.exec_()
......@@ -283,7 +283,7 @@
<string>Convert To:</string>
</property>
</widget>
<widget class="QPushButton" name="convert">
<widget class="QPushButton" name="convertButton">
<property name="geometry">
<rect>
<x>130</x>
......
......@@ -6,13 +6,20 @@
# SPDX - License - Identifier: GPL - 3.0 +
#pylint: disable=invalid-name
from __future__ import (absolute_import, division, print_function)
from .ui_converter import Ui_MainWindow #import line for the UI python class
from PyQt4 import QtCore, QtGui
from qtpy.QtWidgets import QMainWindow, QMessageBox
from qtpy.QtGui import QDoubleValidator
from mantid.kernel import Logger
import math
import TofConverter.convertUnits
try:
from mantidqt.utils.qt import load_ui
except ImportError:
Logger("TofConverter").information('Using legacy ui importer')
from mantidplot import load_ui
class MainWindow(QtGui.QMainWindow):
class MainWindow(QMainWindow):
needsThetaInputList = ['Momentum transfer (Q Angstroms^-1)', 'd-spacing (Angstroms)']
needsThetaOutputList = ['Momentum transfer (Q Angstroms^-1)', 'd-spacing (Angstroms)']
needsFlightPathInputList = ['Time of flight (microseconds)']
......@@ -52,16 +59,15 @@ class MainWindow(QtGui.QMainWindow):
self.flightPathEnable(True)
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self,parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.InputVal.setValidator(QtGui.QDoubleValidator(self.ui.InputVal))
self.ui.totalFlightPathInput.setValidator(QtGui.QDoubleValidator(self.ui.totalFlightPathInput))
self.ui.scatteringAngleInput.setValidator(QtGui.QDoubleValidator(self.ui.scatteringAngleInput))
QtCore.QObject.connect(self.ui.convert, QtCore.SIGNAL("clicked()"), self.convert )
QtCore.QObject.connect(self.ui.helpButton, QtCore.SIGNAL("clicked()"), self.helpClicked)
QtCore.QObject.connect(self.ui.inputUnits, QtCore.SIGNAL("currentIndexChanged(QString)"), self.setInstrumentInputs )
QtCore.QObject.connect(self.ui.outputUnits, QtCore.SIGNAL("currentIndexChanged(QString)"), self.setInstrumentInputs )
QMainWindow.__init__(self,parent)
self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
self.ui.totalFlightPathInput.setValidator(QDoubleValidator(self.ui.totalFlightPathInput))
self.ui.scatteringAngleInput.setValidator(QDoubleValidator(self.ui.scatteringAngleInput))
self.ui.convertButton.clicked.connect(self.convert)
self.ui.helpButton.clicked.connect(self.helpClicked)
self.ui.inputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
self.ui.outputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
self.setInstrumentInputs()
##defaults
......@@ -104,11 +110,11 @@ class MainWindow(QtGui.QMainWindow):
self.ui.convertedVal.clear()
self.ui.convertedVal.insert(str(self.output))
except UnboundLocalError as ule:
QtGui.QMessageBox.warning(self, "TofConverter", str(ule))
QMessageBox.warning(self, "TofConverter", str(ule))
return
except ArithmeticError as ae:
QtGui.QMessageBox.warning(self, "TofConverter", str(ae))
QMessageBox.warning(self, "TofConverter", str(ae))
return
except RuntimeError as re:
QtGui.QMessageBox.warning(self, "TofConverter", str(re))
QMessageBox.warning(self, "TofConverter", str(re))
return
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment