示例#1
0
    def __init__(self):
        super(TextFieldInputPromptExample, self).__init__()

        # add some 'air' to the layout
        self.setSpacing(True)

        self.setMargin(True, False, False, False)

        # Username field + input prompt
        username = TextField()
        username.setInputPrompt('Username')

        # configure & add to layout
        username.setImmediate(True)
        username.addListener(self, IValueChangeListener)
        self.addComponent(username)

        # Password field + input prompt
        password = PasswordField()
        password.setInputPrompt('Password')

        # configure & add to layout
        password.setImmediate(True)
        password.addListener(self, IValueChangeListener)
        self.addComponent(password)

        # Comment field + input prompt
        comment = TextArea()
        comment.setInputPrompt('Comment')

        # configure & add to layout
        comment.setRows(3)
        comment.setImmediate(True)
        comment.addListener(self, IValueChangeListener)
        self.addComponent(comment)
示例#2
0
    def __init__(self):
        super(ValidationExample, self).__init__()

        self._usernames = set()

        self.setSpacing(True)

        pin = TextField('PIN')
        pin.setWidth('50px')
        # optional; validate at once instead of when clicking 'save' (e.g)
        pin.setImmediate(True)
        self.addComponent(pin)
        # add the validator
        pin.addValidator(StringLengthValidator('Must be 4-6 characters',
                4, 6, False))

        username = TextField('Username')
        # optional; validate at once instead of when clicking 'save' (e.g)
        username.setImmediate(True)
        self.addComponent(username)
        usernameValidator = CompositeValidator()
        username.addValidator(usernameValidator)
        usernameValidator.addValidator(StringLengthValidator('Username'
                ' must be at least 4 characters', 4, 255, False))

        usernameValidator.addValidator(UsernameValidator(self))

        username.addListener(UsernameListener(self), IValueChangeListener)
示例#3
0
class TextEditor ( Editor, IValueChangeListener ):
    """ Base class for text style editors, which displays an editable text
    field, containing a text representation of the object trait value.
    """
    #---------------------------------------------------------------------------
    #  Finishes initializing the editor by creating the underlying toolkit
    #  widget:
    #---------------------------------------------------------------------------

    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = TextField()
        self.control.setValue( str(self.str_value) )
        self.control.addListener(self, IValueChangeListener)
        self.set_tooltip()

    #---------------------------------------------------------------------------
    #  Handles the user changing the contents of the edit control:
    #---------------------------------------------------------------------------

    def valueChange(self, event):
        """ Handles the user changing the contents of the edit control.
        """
        try:
            self.value = unicode(self.control.getValue())
        except TraitError:
            pass
    def __init__(self):
        super(TextFieldInputPromptExample, self).__init__()

        # add some 'air' to the layout
        self.setSpacing(True)

        self.setMargin(True, False, False, False)

        # Username field + input prompt
        username = TextField()
        username.setInputPrompt('Username')

        # configure & add to layout
        username.setImmediate(True)
        username.addListener(self, IValueChangeListener)
        self.addComponent(username)

        # Password field + input prompt
        password = PasswordField()
        password.setInputPrompt('Password')

        # configure & add to layout
        password.setImmediate(True)
        password.addListener(self, IValueChangeListener)
        self.addComponent(password)

        # Comment field + input prompt
        comment = TextArea()
        comment.setInputPrompt('Comment')

        # configure & add to layout
        comment.setRows(3)
        comment.setImmediate(True)
        comment.addListener(self, IValueChangeListener)
        self.addComponent(comment)
示例#5
0
    def __init__(self):
        super(ValidationExample, self).__init__()

        self._usernames = set()

        self.setSpacing(True)

        pin = TextField('PIN')
        pin.setWidth('50px')
        # optional; validate at once instead of when clicking 'save' (e.g)
        pin.setImmediate(True)
        self.addComponent(pin)
        # add the validator
        pin.addValidator(
            StringLengthValidator('Must be 4-6 characters', 4, 6, False))

        username = TextField('Username')
        # optional; validate at once instead of when clicking 'save' (e.g)
        username.setImmediate(True)
        self.addComponent(username)
        usernameValidator = CompositeValidator()
        username.addValidator(usernameValidator)
        usernameValidator.addValidator(
            StringLengthValidator('Username'
                                  ' must be at least 4 characters', 4, 255,
                                  False))

        usernameValidator.addValidator(UsernameValidator(self))

        username.addListener(UsernameListener(self), IValueChangeListener)
示例#6
0
 def initFilteringControls(self):
     for pn in self._visibleCols:
         sf = TextField()
         self._bottomLeftCorner.addComponent(sf)
         sf.setWidth("100%")
         sf.setValue(pn)
         sf.setImmediate(True)
         self._bottomLeftCorner.setExpandRatio(sf, 1)
         sf.addListener(TextChangeListener(pn, sf, self),
                 IValueChangeListener)
class TextFieldSingleExample(VerticalLayout, IValueChangeListener):
    def __init__(self):
        super(TextFieldSingleExample, self).__init__()

        self.setSpacing(True)

        self._editor = TextField('Echo this:')
        self._editor.addListener(self, IValueChangeListener)
        self._editor.setImmediate(True)
        # editor.setColumns(5)  # guarantees that at least 5 chars fit
        self.addComponent(self._editor)

    # Catch the valuechange event of the textfield and update the value of the
    # label component
    def valueChange(self, event):
        # Show the new value we received
        self.getWindow().showNotification(self._editor.getValue())
示例#8
0
class TextFieldSingleExample(VerticalLayout, IValueChangeListener):

    def __init__(self):
        super(TextFieldSingleExample, self).__init__()

        self.setSpacing(True)

        self._editor = TextField('Echo this:')
        self._editor.addListener(self, IValueChangeListener)
        self._editor.setImmediate(True)
        # editor.setColumns(5)  # guarantees that at least 5 chars fit
        self.addComponent(self._editor)

    # Catch the valuechange event of the textfield and update the value of the
    # label component
    def valueChange(self, event):
        # Show the new value we received
        self.getWindow().showNotification(self._editor.getValue())
    def __init__(self):
        super(TextFieldTextChangeEventExample, self).__init__()

        nameContainer = ExampleUtil.getNameContainer()
        filterField = TextField('Filter')
        filterField.setTextChangeEventMode(TextChangeEventMode.LAZY)
        filterField.setTextChangeTimeout(200)

        filterField.addListener(FilterListener(nameContainer),
                ITextChangeListener)
        table = Table(None, nameContainer)
        table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN)

        self.setSpacing(False)

        self.addComponent(filterField)
        self.addComponent(table)

        filterField.setWidth('150px')
        table.setWidth('150px')