def _createSettingsPres(self): def _listener(attrName): class _Listener(TextEntry.TextEntryListener): def onTextChanged(listener, textEntry): if textEntry.isDisplayedTextValid(): setattr(self, attrName, int(textEntry.getDisplayedText())) self._incr.onChanged() return _Listener() min = [ Label('Min'), TextEntry(str(self._min), _listener('_min')).regexValidated( Tokens.decimalIntegerPattern, 'Please enter an integer value') ] max = [ Label('Max'), TextEntry(str(self._max), _listener('_max')).regexValidated( Tokens.decimalIntegerPattern, 'Please enter an integer value') ] step = [ Label('Step'), TextEntry(str(self._step), _listener('_step')).regexValidated( Tokens.decimalIntegerPattern, 'Please enter an integer value') ] page = [ Label('Page'), TextEntry(str(self._page), _listener('_page')).regexValidated( Tokens.decimalIntegerPattern, 'Please enter an integer value') ] return Table([min, max, step, page])
def _onRename(menuItem): textEntry = TextEntry(package.name, _RenameListener()).regexValidated( _nameRegex, 'Please enter a valid identifier') textEntry.grabCaretOnRealise() nameLive.setLiteralValue(textEntry)
def _editUIFormSections(self): expr = Form.SmallSection('Expression', None, self.expr.editUI()) displayedText = Form.SmallSection( 'Displayed text', None, TextEntry.textEntryCommitOnChange(self.displayedText.live)) superSections = super(GUIEval, self)._editUIFormSections() return [expr, displayedText] + superSections
def _editUIFormSections(self): text = Form.SmallSection( 'Text', None, self.text.editUI( lambda live: TextEntry.textEntryCommitOnChange(live))) superSections = super(GUIText, self)._editUIFormSections() return [text] + superSections
def unaryBranchChildEditUIFormSections(branch): child = branch.child.node if child is not None: if isinstance(child, GUIEditor.PrimitiveComponents.GUILabel): textField = child.text if textField.isConstant(): textLive = textField.constantValueLive return [Form.SmallSection('Label text', None, TextEntry.textEntryCommitOnChange(textLive))] return []
def control(): if not elem.is_textual(): return error.error_message('Element has non-textual content') else: class Listener(TextEntry.TextEntryListener): def onAccept(l, control, text): elem.contents[:] = [text] return TextEntry(elem.as_text_live, Listener())
def control(): try: elem = fn() except xmlmodel.XmlElemNoChildMatchesSelector: return error.error_message('Query did not match any elements') except xmlmodel.XmlElemMultipleChildrenMatchSelectorError: return error.error_message('Query matched multiple elements') if not elem.is_textual(): return error.error_message('Element has non-textual content') else: class Listener(TextEntry.TextEntryListener): def onAccept(l, control, text): elem.contents[:] = [text] return TextEntry(elem.as_text_live, Listener())
def buildEditorPres(self, fragment, inheritedState): return TextEntry(self._model.liveValue)
def _dropPrompt(varNameTextEntryListener): textEntry = TextEntry( 'var', varNameTextEntryListener ).regexValidated( _varNameRegex, 'Please enter a valid identifier' ) prompt = Label( 'Place object into a variable named: ' ) textEntry.grabCaretOnRealise() textEntry.selectAllOnRealise() return _dropPromptStyle.applyTo( Border( Paragraph( [ prompt.alignVCentre(), textEntry.alignVCentre() ] ).alignHPack() ) )
def _onNameButton(button, event): nameEntry = TextEntry(self._definition._name, _NameEntryListener()) nameEntry.grabCaretOnRealise() nameEntry = self._nameStyle(nameEntry) liveName.setLiteralValue(nameEntry)