def createEditor(self, parent, option, index): editor = QLineEdit(parent) # Autocompletion for selection criteria! GuiLM = GuiLabelManager() comp_list = GuiLM.getCompleter("mesh_selection") comp_list += GuiLM.getCompleter("mesh_normal") completer = QCompleter() editor.setCompleter(completer) model = QStringListModel() completer.setModel(model) model.setStringList(comp_list) return editor
def createEditor(self, parent, option, index): editor = QLineEdit(parent) validator = RegExpValidator(editor, QRegExp("[ -~]*")) editor.setValidator(validator) # Autocompletion for selection criteria! comp_list = GuiLabelManager().getCompleter('mesh_selection') completer = QCompleter() editor.setCompleter(completer) model = QStringListModel() completer.setModel(model) model.setStringList(comp_list) return editor
from code_saturne.Pages.NotebookForm import Ui_NotebookForm from code_saturne.model.NotebookModel import NotebookModel #------------------------------------------------------------------------------- # log config #------------------------------------------------------------------------------- logging.basicConfig() log = logging.getLogger("NotebookView") log.setLevel(GuiParam.DEBUG) #------------------------------------------------------------------------------- # List of labels which are forbidden as notebook variables names #------------------------------------------------------------------------------- _forbidden_labels = GuiLabelManager().getForbidden("notebook") #------------------------------------------------------------------------------- # item class #------------------------------------------------------------------------------- class item_class(object): ''' custom data object ''' def __init__(self, idx, name, value, oturns_var, editable, description): self.index = idx self.name = name self.value = value self.oturns = oturns_var self.edit = editable
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_CathareCouplingForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() self.__model = CathareCouplingModel(self.case) # Main combo box self.activateCathareCpl = QtPage.ComboModel(self.comboBoxActiveCpl, 2, 1) self.activateCathareCpl.addItem(self.tr("No coupling"), "off") self.activateCathareCpl.addItem(self.tr("Activate coupling"), "on") # Models self.modelCathare = StandardItemModelCathare(self.__model) self.tableViewCathare.setModel(self.modelCathare) if QT_API == "PYQT4": self.tableViewCathare.verticalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewCathare.horizontalHeader().setResizeMode( QHeaderView.ResizeToContents) self.tableViewCathare.horizontalHeader().setResizeMode( 4, QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewCathare.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewCathare.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tableViewCathare.horizontalHeader().setSectionResizeMode( 4, QHeaderView.Stretch) delegateCathareElt = LabelDelegate(self.tableViewCathare) self.tableViewCathare.setItemDelegateForColumn(0, delegateCathareElt) delegateCathareFCell = LabelDelegate(self.tableViewCathare) self.tableViewCathare.setItemDelegateForColumn(1, delegateCathareFCell) delegateCathareLCell = LabelDelegate(self.tableViewCathare) self.tableViewCathare.setItemDelegateForColumn(2, delegateCathareLCell) ncfdBcList = ['off'] ncfdBcState = ['na'] if self.case: d = LocalizationModel('BoundaryZone', self.case) for zone in d.getZones(): ncfdBcList.append(zone.getLabel()) ncfdBcState.append("on") delegateNeptuneBc = ComboDelegate(self.tableViewCathare, opts_list=ncfdBcList, opts_state=ncfdBcState) self.tableViewCathare.setItemDelegateForColumn(3, delegateNeptuneBc) # Create a selection delegate with autocompletion for mesh # selection examples _comp_list = GuiLabelManager().getCompleter("mesh_selection") delegateNeptune1dZone = LabelDelegate(self.tableViewCathare, xml_model=self.__model, accepted_regex="[ -~]*", auto_completion=_comp_list) self.tableViewCathare.setItemDelegateForColumn(4, delegateNeptune1dZone) # Connections self.pushButtonAdd.clicked.connect(self.slotAddCathare) self.pushButtonDelete.clicked.connect(self.slotDeleteCathare) self.comboBoxActiveCpl.activated[str].connect(self.slotActivateCpl) self.radioButtonOnePhase.clicked.connect(self.slotOnePhase) self.radioButtonAllPhases.clicked.connect(self.slotAllPhases) self.lineEditCathareFile.textChanged[str].connect(self.slotCathareFile) self.toolButtonCathareFile.pressed.connect(self.searchCathareJDD) self.lineEditCplName.textChanged[str].connect(self.slotCplName) self.lineEditCplTime.textChanged[str].connect(self.slotCplTime) self.lineEditCathareInitTime.textChanged[str].connect( self.slotCathareTime) self.lineEditCathareInstance.textChanged[str].connect( self.slotCathareInstanceName) self.toolButtonCathareInstance.pressed.connect(self.searchCathareDir) self.lineEditNeptuneInstance.textChanged[str].connect( self.slotNeptuneInstanceName) self.toolButtonNeptuneInstance.pressed.connect(self.searchNeptuneDir) # Insert list of Cathare couplings for view for c in self.__model.getCathareCouplingList(): [ cathare_elt, cathare_first_cell, cathare_last_cell, neptune_bc, neptune_1d_zone ] = c self.modelCathare.addItem(cathare_elt, cathare_first_cell, cathare_last_cell, neptune_bc, neptune_1d_zone) # ------------------------------------------ # Activate the coupling parameters if needed if self.__model.getCathareActivationStatus() != 0: self.activateCathareCpl.setItem(str_model="on") if self.__getActivationState() == 'off': self.groupBoxCathareCpls.hide() self.groupBoxCplParameters.hide() else: self.groupBoxCathareCpls.show() self.groupBoxCplParameters.show() # ------------------------------------------ if self.__model.getNphases() == 0 or self.__model.getNphases() == 1: self.radioButtonOnePhase.setChecked(True) self.radioButtonAllPhases.setChecked(False) else: self.radioButtonOnePhase.setChecked(False) self.radioButtonAllPhases.setChecked(True) # ------------------------------------------ if self.__getActivationState() == 'on': self.lineEditCathareFile.setText(str( self.__model.getCathareFile())) self.lineEditCplName.setText(str(self.__model.getCplName())) self.lineEditCplTime.setText(str(self.__model.getCplTime())) self.lineEditCathareInitTime.setText( str(self.__model.getCathareTime())) self.lineEditCathareInstance.setText( str(self.__model.getCathareInstanceName())) self.lineEditNeptuneInstance.setText( str(self.__model.getNeptuneInstanceName())) # ------------------------------------------ self.case.undoStartGlobal()
def __init__(self, parent, case): """ Constructor. """ QWidget.__init__(self, parent) Ui_BalanceForm.__init__(self) self.setupUi(self) self.case = case self.case.undoStopGlobal() if self.case.xmlRootNode().tagName == "Code_Saturne_GUI": from code_saturne.model.BalanceModel import BalanceModel self.mdl = BalanceModel(self.case) elif self.case.xmlRootNode().tagName == "NEPTUNE_CFD_GUI": from code_saturne.model.BalanceModelNeptune import BalanceModelNeptune self.mdl = BalanceModelNeptune(self.case) # Autocompletion for zone selection _zone_autocompletion = GuiLabelManager().getCompleter("mesh_selection") # tableView Pressure Drop self.pressureModel = StandardItemModelPressureDrop(self.mdl) self.tableViewPressureDrop.setModel(self.pressureModel) self.tableViewPressureDrop.setAlternatingRowColors(True) self.tableViewPressureDrop.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableViewPressureDrop.setSelectionMode(QAbstractItemView.SingleSelection) delegateIdxPres = IntegerDelegate(self.tableViewPressureDrop, minVal=0) self.tableViewPressureDrop.setItemDelegateForColumn(0, delegateIdxPres) delegateSelector = LabelDelegate(self.tableViewPressureDrop, auto_completion=_zone_autocompletion) self.tableViewPressureDrop.setItemDelegateForColumn(1, delegateSelector) self.tableViewPressureDrop.resizeColumnsToContents() self.tableViewPressureDrop.resizeRowsToContents() if QT_API == "PYQT4": self.tableViewPressureDrop.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewPressureDrop.horizontalHeader().setSectionResizeMode(1,QHeaderView.Stretch) # tableView scalar balance self.modelScalarBalance = StandardItemModelScalarBalance(self.mdl) self.tableViewScalarBalance.setModel(self.modelScalarBalance) self.tableViewScalarBalance.resizeColumnToContents(0) self.tableViewScalarBalance.setAlternatingRowColors(True) self.tableViewScalarBalance.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableViewScalarBalance.setSelectionMode(QAbstractItemView.SingleSelection) delegateIdxScalar = IntegerDelegate(self.tableViewScalarBalance, minVal=0) self.tableViewScalarBalance.setItemDelegateForColumn(0, delegateIdxScalar) delegateVariable = LabelDelegate(self.tableViewScalarBalance, auto_completion=_zone_autocompletion) self.tableViewScalarBalance.setItemDelegateForColumn(1, delegateVariable) delegateSelector = LabelDelegate(self.tableViewScalarBalance) self.tableViewScalarBalance.setItemDelegateForColumn(1, delegateSelector) self.tableViewScalarBalance.resizeColumnsToContents() self.tableViewScalarBalance.resizeRowsToContents() if QT_API == "PYQT4": self.tableViewScalarBalance.horizontalHeader().setResizeMode(2,QHeaderView.Stretch) elif QT_API == "PYQT5": self.tableViewScalarBalance.horizontalHeader().setSectionResizeMode(2,QHeaderView.Stretch) # QListView layout self.gridlayout1 = QGridLayout(self.widgetDrag) self.gridlayout1.setContentsMargins(0, 0, 0, 0) self.DragList = QListView(self.widgetDrag) self.gridlayout1.addWidget(self.DragList,0,0,1,1) self.gridlayout2 = QGridLayout(self.widgetDrop) self.gridlayout2.setContentsMargins(0, 0, 0, 0) self.DropList = QListView(self.widgetDrop) self.gridlayout2.addWidget(self.DropList,0,0,1,1) self.modelDrag = QStringListModel() self.modelDrop = QStringListModel() self.DragList.setModel(self.modelDrag) self.DropList.setModel(self.modelDrop) self.DragList.setAlternatingRowColors(True) self.DragList.setEditTriggers(QAbstractItemView.NoEditTriggers) self.DropList.setAlternatingRowColors(True) self.DropList.setEditTriggers(QAbstractItemView.NoEditTriggers) # Connections self.pushButtonAddPressureDrop.clicked.connect(self.slotAddPressureDrop) self.pushButtonDeletePressureDrop.clicked.connect(self.slotDeletePressureDrop) self.tableViewScalarBalance.pressed[QModelIndex].connect(self.slotSelectScalarBalance) self.pushButtonAddScalarBalance.clicked.connect(self.slotAddScalarBalance) self.pushButtonDeleteScalarBalance.clicked.connect(self.slotDeleteScalarBalance) self.pushButtonAddVar.clicked.connect(self.slotAddVarProfile) self.pushButtonSuppressVar.clicked.connect(self.slotDeleteVarProfile) if self.mdl.getPressureDropList() != None: for i in range(len(self.mdl.getPressureDropList())): self.pressureModel.addItem(i) if self.mdl.getScalarBalanceList() != None: for i in range(len(self.mdl.getScalarBalanceList())): self.modelScalarBalance.addItem(i) #update list of variables, properties, scalars ... liste_label = [] for label in self.mdl.getScalarVariables(): liste_label.append(label) self.modelDrag.setStringList(sorted(liste_label, key=str.lower)) self.__eraseEntries() self.case.undoStartGlobal()