def __init__(self, *args, **kwargs):
     super(SpectraControlWidget, self).__init__(*args, **kwargs)
     self._energy = (kwargs.get('energy', None))
     self._energyMin = 0.
     self._energyMax = 1.
     self._intensityMax = 1.
     self._chi2 = np.nan
     self._spectra = []
     self._controls = []
     
     # Construct a summed spectrum
     self.summedSpectrum = SummedSpectrum()
     
     # Construct widgets
     self.parameterEdit = BoundedFloatParameterEdit(
                                         orientation=QtCore.Qt.Horizontal)
     addConstantButton = QtGui.QPushButton('Add Constant')
     addGaussianButton = QtGui.QPushButton('Add Gaussian')
     addLorentzianButton = QtGui.QPushButton('Add Lorentzian')
     addAsymmetricGaussianButton = QtGui.QPushButton('Add Asymmetric Gaussian')
     addWaveVectorConservingPLButton = (
                 QtGui.QPushButton('Add wave vector conserving PL'))
     addWaveVectorNonConservingPLButton = (
                 QtGui.QPushButton('Add wave vector non-conserving PL'))
     addConstantButton.setMinimumHeight(40)
     addGaussianButton.setMinimumHeight(40)
     addLorentzianButton.setMinimumHeight(40)
     addAsymmetricGaussianButton.setMinimumHeight(40)
     addWaveVectorConservingPLButton.setMinimumHeight(40)
     addWaveVectorNonConservingPLButton.setMinimumHeight(40)
     
     # Scroll area for the SpectrumWidgets
     scrollWidget = QtGui.QWidget()
     scroll = VerticalScrollArea()
     scroll.setWidget(scrollWidget)
     
     # Layout
     layout = QtGui.QVBoxLayout(self)
     layout.setSpacing(5)
     layout.addWidget(self.parameterEdit)
     layout.addWidget(scroll, stretch=1)
     self.scrollLayout = QtGui.QVBoxLayout(scrollWidget)
     self.scrollLayout.addStretch(1)
     layout.addWidget(addConstantButton)
     layout.addWidget(addGaussianButton)
     layout.addWidget(addLorentzianButton)
     layout.addWidget(addAsymmetricGaussianButton)
     layout.addWidget(addWaveVectorConservingPLButton)
     layout.addWidget(addWaveVectorNonConservingPLButton)
     
     # Connect signals and slots
     addConstantButton.clicked.connect(self.addConstantSpectrum)
     addGaussianButton.clicked.connect(self.addGaussianSpectrum)
     addLorentzianButton.clicked.connect(self.addLorentzianSpectrum)
     addAsymmetricGaussianButton.clicked.connect(self.addAsymmetricGaussianSpectrum)
     addWaveVectorConservingPLButton.clicked.connect(
                                 self.addWaveVectorConservingPLSpectrum)
     addWaveVectorNonConservingPLButton.clicked.connect(
                                 self.addWaveVectorNonConservingPLSpectrum)
예제 #2
0
    app = QtGui.QApplication([])
    w = QtGui.QWidget()
    s1 = ConstantSpectrum()
    s2 = GaussianSpectrum()
    s3 = LorentzianSpectrum()
    sc1 = SpectrumControlWidget(s1)
    # sc1.setStyleSheet("QObject { background-color: blue; }")
    sc2 = SpectrumControlWidget(s2)
    # sc2.setStyleSheet("QObject { background-color: red; }")
    sc3 = SpectrumControlWidget(s3)
    # sc3.setStyleSheet("QObject { background-color: green; }")
    layout = QtGui.QVBoxLayout(w)
    # layout.setSpacing(0)
    # layout.setContentsMargins(0, 0, 0, 0)
    layout.addWidget(sc1)
    layout.addWidget(sc2)
    layout.addWidget(sc3)
    layout.addStretch(1)
    # w.show()
    # w.raise_()
    scroll = VerticalScrollArea()
    scroll.setWidget(w)
    scroll.show()
    scroll.raise_()

    import sys

    if (sys.flags.interactive != 1) or not hasattr(QtCore, "PYQT_VERSION"):
        QtGui.QApplication.instance().exec_()