Changeset fec5842 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
- Timestamp:
- Mar 28, 2019 12:01:39 PM (5 years ago)
- Branches:
- ESS_GUI_bumps_abstraction
- Children:
- ccfe03b
- Parents:
- 22b4962
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
r22b4962 rfec5842 201 201 # disable the context help icon 202 202 self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) 203 203 self.setWindowTitle("Fit Algorithms") 204 204 # no reason to have this widget resizable 205 self.setFixedSize(self.minimumSizeHint()) 206 self.setWindowTitle("Fit Algorithms") 205 self.layout().setSizeConstraint(QtWidgets.QLayout.SetFixedSize) 207 206 208 207 # Fill up the algorithm combo, based on what BUMPS says is available … … 221 220 self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.onHelp) 222 221 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 223 228 # Handle the combo box changes 224 229 self.cbAlgorithm.currentIndexChanged.connect(self.onAlgorithmChange) 225 230 226 # Set the default index 231 # Set the default index and trigger filling the layout 227 232 default_index = self.cbAlgorithm.findText(self.fittingMethods.default.longName) 228 233 self.cbAlgorithm.setCurrentIndex(default_index) 229 # previous algorithm choice230 self.previous_index = default_index231 232 # Assign appropriate validators233 self.assignValidators()234 235 # Set defaults236 self.current_fitter_id = self.fittingMethods.default.shortName237 238 # OK has to be initialized to True, after initial validator setup239 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)240 234 241 235 def assignValidators(self): … … 277 271 for i in reversed(list(range(layout.count()))): 278 272 # reversed removal avoids renumbering possibly 279 item = layout.itemAt(i)280 try:281 if item.widget().objectName() == "cbAlgorithm":282 continue283 except AttributeError:284 pass285 273 item = layout.takeAt(i) 286 274 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 287 277 item.widget().setParent(None) 288 278 item.widget().deleteLater() … … 294 284 lbl = QtWidgets.QLabel(name + ":") 295 285 lbl.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 286 lbl.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, 287 QtWidgets.QSizePolicy.Fixed)) 296 288 lbl.setWordWrap(True) 297 289 return lbl … … 313 305 fm = self.fittingMethods[self.currentOptimizer] 314 306 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) 317 308 for param in fm.params.values(): 318 row , column = layout.rowCount()+1, layout.columnCount()309 row = layout.rowCount()+1 319 310 layout.addWidget(self._makeLabel(param.longName), row, 0) 320 311 widget = self._inputWidgetFromType(param.type, self) … … 336 327 self._fillLayout() 337 328 338 if selectedName in self.fittingMethods.longNames:339 self.current_fitter_id = self.fittingMethods[selectedName].shortName340 341 # find the right stacked widget342 widget_name = "self.page_"+str(self.current_fitter_id)343 344 # Convert the name into widget instance345 try:346 widget_to_activate = eval(widget_name)347 except AttributeError:348 # We don't yet have this optimizer.349 # Show message350 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 position357 self.cbAlgorithm.setCurrentIndex(self.previous_index)358 return359 360 329 # Select the requested widget 361 330 self.updateWidgetFromConfig() … … 364 333 # OK has to be reinitialized to True 365 334 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 366 367 # keep reference368 self.previous_index = index369 335 370 336 def paramWidget(self, fittingMethod, paramShortName): … … 422 388 # Note that we can be clusmy here, since bad current_fitter_id 423 389 # 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 425 392 help_location = tree_location + helpfile 426 393 webbrowser.open('file://' + os.path.realpath(help_location))
Note: See TracChangeset
for help on using the changeset viewer.