Ignore:
Timestamp:
Mar 28, 2019 12:01:39 PM (5 years ago)
Author:
ibressler
Branches:
ESS_GUI_bumps_abstraction
Children:
ccfe03b
Parents:
22b4962
Message:

FittingOptions?: removed stackWidget from .UI, fixed layout issues, removed obsolete code

  • fitting method parameter tooltips will be back soon
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    r22b4962 rfec5842  
    201201        # disable the context help icon 
    202202        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) 
    203  
     203        self.setWindowTitle("Fit Algorithms") 
    204204        # no reason to have this widget resizable 
    205         self.setFixedSize(self.minimumSizeHint()) 
    206         self.setWindowTitle("Fit Algorithms") 
     205        self.layout().setSizeConstraint(QtWidgets.QLayout.SetFixedSize) 
    207206 
    208207        # Fill up the algorithm combo, based on what BUMPS says is available 
     
    221220        self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.onHelp) 
    222221 
     222        # Assign appropriate validators 
     223        self.assignValidators() 
     224 
     225        # OK has to be initialized to True, after initial validator setup 
     226        self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
     227 
    223228        # Handle the combo box changes 
    224229        self.cbAlgorithm.currentIndexChanged.connect(self.onAlgorithmChange) 
    225230 
    226         # Set the default index 
     231        # Set the default index and trigger filling the layout 
    227232        default_index = self.cbAlgorithm.findText(self.fittingMethods.default.longName) 
    228233        self.cbAlgorithm.setCurrentIndex(default_index) 
    229         # previous algorithm choice 
    230         self.previous_index = default_index 
    231  
    232         # Assign appropriate validators 
    233         self.assignValidators() 
    234  
    235         # Set defaults 
    236         self.current_fitter_id = self.fittingMethods.default.shortName 
    237  
    238         # OK has to be initialized to True, after initial validator setup 
    239         self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
    240234 
    241235    def assignValidators(self): 
     
    277271        for i in reversed(list(range(layout.count()))): 
    278272            # reversed removal avoids renumbering possibly 
    279             item = layout.itemAt(i) 
    280             try: 
    281                 if item.widget().objectName() == "cbAlgorithm": 
    282                     continue 
    283             except AttributeError: 
    284                 pass 
    285273            item = layout.takeAt(i) 
    286274            try: # spaceritem does not have a widget 
     275                if item.widget().objectName() == "cbAlgorithm": 
     276                    continue # do not delete the checkbox, will be added later again 
    287277                item.widget().setParent(None) 
    288278                item.widget().deleteLater() 
     
    294284        lbl = QtWidgets.QLabel(name + ":") 
    295285        lbl.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 
     286        lbl.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, 
     287                                                QtWidgets.QSizePolicy.Fixed)) 
    296288        lbl.setWordWrap(True) 
    297289        return lbl 
     
    313305        fm = self.fittingMethods[self.currentOptimizer] 
    314306        layout = self.groupBox.layout() 
    315         # label for the name of the optimizer, span the whole row 
    316         layout.addWidget(self._makeLabel(fm.longName), layout.rowCount()+1, 0, 1, -1) 
     307        layout.addWidget(self.cbAlgorithm, 0, 0, 1, -1) 
    317308        for param in fm.params.values(): 
    318             row, column = layout.rowCount()+1, layout.columnCount() 
     309            row = layout.rowCount()+1 
    319310            layout.addWidget(self._makeLabel(param.longName), row, 0) 
    320311            widget = self._inputWidgetFromType(param.type, self) 
     
    336327        self._fillLayout() 
    337328 
    338         if selectedName in self.fittingMethods.longNames: 
    339             self.current_fitter_id = self.fittingMethods[selectedName].shortName 
    340  
    341         # find the right stacked widget 
    342         widget_name = "self.page_"+str(self.current_fitter_id) 
    343  
    344         # Convert the name into widget instance 
    345         try: 
    346             widget_to_activate = eval(widget_name) 
    347         except AttributeError: 
    348             # We don't yet have this optimizer. 
    349             # Show message 
    350             msg = "This algorithm has not yet been implemented in SasView.\n" 
    351             msg += "Please choose a different algorithm" 
    352             QtWidgets.QMessageBox.warning(self, 
    353                                         'Warning', 
    354                                         msg, 
    355                                         QtWidgets.QMessageBox.Ok) 
    356             # Move the index to previous position 
    357             self.cbAlgorithm.setCurrentIndex(self.previous_index) 
    358             return 
    359  
    360329        # Select the requested widget 
    361330        self.updateWidgetFromConfig() 
     
    364333        # OK has to be reinitialized to True 
    365334        self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 
    366  
    367         # keep reference 
    368         self.previous_index = index 
    369335 
    370336    def paramWidget(self, fittingMethod, paramShortName): 
     
    422388        # Note that we can be clusmy here, since bad current_fitter_id 
    423389        # will just make the page displayed from the top 
    424         helpfile = "optimizer.html#fit-" + self.current_fitter_id  
     390        current_fitter_id = self.fittingMethods[self.currentOptimizer].shortName 
     391        helpfile = "optimizer.html#fit-" + current_fitter_id 
    425392        help_location = tree_location + helpfile 
    426393        webbrowser.open('file://' + os.path.realpath(help_location)) 
Note: See TracChangeset for help on using the changeset viewer.