Changeset 1d85b5e in sasview for src/sas/qtgui/DensityPanel.py


Ignore:
Timestamp:
Oct 20, 2016 9:11:19 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
9968d6a
Parents:
ef36eb2
Message:

Linked two new calculators to the Gui Manager.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/DensityPanel.py

    r6083d6e r1d85b5e  
    11# global 
    22import logging 
     3import functools 
     4 
    35from periodictable import formula as Formula 
    46 
     
    5961 
    6062    def __init__(self, parent=None): 
    61         super(DensityPanel, self).__init__(parent) 
     63        super(DensityPanel, self).__init__() 
    6264 
    6365        self.mode = None 
    64  
     66        self.manager = parent 
    6567        self.setupUi() 
    6668        self.setupModel() 
     
    7981 
    8082        # signals 
    81         QtCore.QObject.connect( 
    82             self.ui.editMolarVolume, 
    83             QtCore.SIGNAL("textEdited(QString)"), 
    84             lambda text: self.setMode(MODES.VOLUME_TO_DENSITY)) 
    85         QtCore.QObject.connect( 
    86             self.ui.editMassDensity, 
    87             QtCore.SIGNAL("textEdited(QString)"), 
    88             lambda text: self.setMode(MODES.DENSITY_TO_VOLUME)) 
    89         QtCore.QObject.connect( 
    90             self.ui.buttonBox.button(QtGui.QDialogButtonBox.Reset), 
    91             QtCore.SIGNAL("clicked(bool)"), 
    92             lambda checked: self.modelReset()) 
     83        self.ui.editMolarVolume.textEdited.connect(functools.partial(self.setMode, MODES.VOLUME_TO_DENSITY)) 
     84        self.ui.editMassDensity.textEdited.connect(functools.partial(self.setMode, MODES.DENSITY_TO_VOLUME)) 
     85 
     86        self.ui.buttonBox.button(QtGui.QDialogButtonBox.Reset).clicked.connect(self.modelReset) 
     87        self.ui.buttonBox.button(QtGui.QDialogButtonBox.Help).clicked.connect(self.displayHelp) 
    9388 
    9489    def setupModel(self): 
     
    9994        self.model.setItem(MODEL.MASS_DENSITY     , QtGui.QStandardItem()) 
    10095 
    101         QtCore.QObject.connect( 
    102             self.model, 
    103             QtCore.SIGNAL("dataChanged(QModelIndex,QModelIndex)"), 
    104             self.dataChanged) 
     96        self.model.dataChanged.connect(self.dataChanged) 
    10597 
    10698        self.modelReset() 
     
    170162            pass 
    171163            #self.model.endResetModel() 
     164 
     165    def displayHelp(self): 
     166        try: 
     167            location = self.manager.HELP_DIRECTORY_LOCATION + \ 
     168                "/user/sasgui/perspectives/calculator/density_calculator_help.html" 
     169            self.manager._helpView.load(QtCore.QUrl(location)) 
     170            self.manager._helpView.show() 
     171        except AttributeError: 
     172            # No manager defined - testing and standalone runs 
     173            pass 
Note: See TracChangeset for help on using the changeset viewer.