示例#1
0
class ReadonlyEditor ( Editor ):
    """ Read-only style of editor for Boolean values, which displays static text
    of either "True" or "False".
    """
    #---------------------------------------------------------------------------
    #  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.setReadOnly(True)
        self.control.setEnabled(False)
        self.control.setWidth('100%')

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #
    #  (Should normally be overridden in a subclass)
    #---------------------------------------------------------------------------

    def update_editor ( self ):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        if self.value:
            self.control.setValue('True')
        else:
            self.control.setValue('False')
示例#2
0
class PopupTextField(popup_view.IContent):

    def __init__(self):
        self._root = VerticalLayout()
        self._tf = TextField('Edit me')

        self._root.setSizeUndefined()
        self._root.setSpacing(True)
        self._root.setMargin(True)
        self._root.addComponent(Label(('The changes made to any components '
                'inside the popup are reflected automatically when the popup '
                'is closed, but you might want to provide explicit action '
                'buttons for the user, like \"Save\" or \"Close\".')))
        self._root.addComponent(self._tf)

        self._tf.setValue('Initial dynamic content')
        self._tf.setWidth('300px')


    def getMinimizedValueAsHTML(self):
        return str(self._tf.getValue())


    def getPopupComponent(self):
        return self._root
示例#3
0
    def __init__(self):
        super(SubwindowAutoSizedExample, self).__init__()

        # Create the window
        self._subwindow = Window('Automatically sized subwindow')

        # Configure the windws layout; by default a VerticalLayout
        layout = self._subwindow.getContent()
        layout.setMargin(True)
        layout.setSpacing(True)

        # make it undefined for auto-sizing window
        layout.setSizeUndefined()

        # Add some content;
        for _ in range(7):
            tf = TextField()
            tf.setWidth('400px')
            self._subwindow.addComponent(tf)

        close = Button('Close', CloseListener(self))

        # The components added to the window are actually added to the window's
        # layout; you can use either. Alignments are set using the layout
        layout.addComponent(close)
        layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT)

        # Add a button for opening the subwindow
        opn = Button('Open sized window', OpenListener(self))
        self.addComponent(opn)
示例#4
0
    def __init__(self):
        super(SubwindowAutoSizedExample, self).__init__()

        # Create the window
        self._subwindow = Window('Automatically sized subwindow')

        # Configure the windws layout; by default a VerticalLayout
        layout = self._subwindow.getContent()
        layout.setMargin(True)
        layout.setSpacing(True)

        # make it undefined for auto-sizing window
        layout.setSizeUndefined()

        # Add some content;
        for _ in range(7):
            tf = TextField()
            tf.setWidth('400px')
            self._subwindow.addComponent(tf)

        close = Button('Close', CloseListener(self))

        # The components added to the window are actually added to the window's
        # layout; you can use either. Alignments are set using the layout
        layout.addComponent(close)
        layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT)

        # Add a button for opening the subwindow
        opn = Button('Open sized window', OpenListener(self))
        self.addComponent(opn)
示例#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 __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)
示例#7
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.addCallback(onFilterChange, property.ValueChangeEvent,
                 pn, sf, self)
示例#8
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)
示例#9
0
    def __init__(self):
        # this is a VerticalLayout
        super(VerticalLayoutBasicExample, self).__init__()

        # let's add some components
        for i in range(5):
            tf = TextField('Row %d' % (i + 1))
            tf.setWidth('300px')
            # Add the component to the VerticalLayout
            self.addComponent(tf)
示例#10
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.addCallback(onFilterChange, property.ValueChangeEvent, pn, sf,
                        self)
 def createVertical(self, recurse):
     wl = WeeLayout(Direction.VERTICAL)
     wl.setSizeFull()
     # wl.setWidth("100%")
     # wl.setHeight("50%")
     wl.addComponent(TextField('Left'), Alignment.TOP_LEFT)
     wl.addComponent(TextField('Center'), Alignment.TOP_CENTER)
     tf = TextField('Right')
     tf.setWidth('50%')
     wl.addComponent(tf, Alignment.TOP_RIGHT)
     if recurse > 0:
         recurse -= 1
         wl.addComponent(self.createHorizontal(recurse))
     return wl
示例#12
0
 def createVertical(self, recurse):
     wl = WeeLayout(Direction.VERTICAL)
     wl.setSizeFull()
     # wl.setWidth("100%")
     # wl.setHeight("50%")
     wl.addComponent(TextField('Left'), Alignment.TOP_LEFT)
     wl.addComponent(TextField('Center'), Alignment.TOP_CENTER)
     tf = TextField('Right')
     tf.setWidth('50%')
     wl.addComponent(tf, Alignment.TOP_RIGHT)
     if recurse > 0:
         recurse -= 1
         wl.addComponent(self.createHorizontal(recurse))
     return wl
示例#13
0
    def __init__(self):
        super(NotificationCustomExample, self).__init__()

        self.setSpacing(True)

        caption = TextField('Caption', 'Message sent')
        caption.setDescription(('Main info; a short caption-only '
                                'notification is often most effective.'))
        caption.setWidth('200px')
        self.addComponent(caption)

        description = RichTextArea()
        description.setWidth('100%')
        description.setValue('<p>to <i>[email protected]</i></p>')
        description.setCaption('Description')
        description.setDescription(('Additional information; '
                                    'try to keep it short.'))
        self.addComponent(description)

        horiz = HorizontalLayout()
        horiz.setSpacing(True)
        self.addComponent(horiz)

        position = NativeSelect('Position')
        position.setNullSelectionAllowed(False)
        horiz.addComponent(position)
        self.initPositionItems(position)

        style = NativeSelect('Style')
        style.setNullSelectionAllowed(False)
        horiz.addComponent(style)
        self.initTypeItems(style)
        delay = Slider('Delay (msec), -1 means click to hide')
        delay.setDescription(
            ('Delay before fading<br/>Pull all the way to '
             'the left to get -1, which means forever (click to hide).'))
        delay.setWidth('100%')  # 'description' will push width
        delay.setMin(Notification.DELAY_FOREVER)
        delay.setMax(10000)
        self.addComponent(delay)

        # TODO icon select

        l = ShowListener(self, caption, description, style, position, delay)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
示例#14
0
    def __init__(self):
        super(NotificationCustomExample, self).__init__()

        self.setSpacing(True)

        caption = TextField('Caption', 'Message sent')
        caption.setDescription(('Main info; a short caption-only '
                'notification is often most effective.'))
        caption.setWidth('200px')
        self.addComponent(caption)

        description = RichTextArea()
        description.setWidth('100%')
        description.setValue('<p>to <i>[email protected]</i></p>')
        description.setCaption('Description')
        description.setDescription(('Additional information; '
                'try to keep it short.'))
        self.addComponent(description)

        horiz = HorizontalLayout()
        horiz.setSpacing(True)
        self.addComponent(horiz)

        position = NativeSelect('Position')
        position.setNullSelectionAllowed(False)
        horiz.addComponent(position)
        self.initPositionItems(position)

        style = NativeSelect('Style')
        style.setNullSelectionAllowed(False)
        horiz.addComponent(style)
        self.initTypeItems(style)
        delay = Slider('Delay (msec), -1 means click to hide')
        delay.setDescription(('Delay before fading<br/>Pull all the way to '
                'the left to get -1, which means forever (click to hide).'))
        delay.setWidth('100%')  # 'description' will push width
        delay.setMin(Notification.DELAY_FOREVER)
        delay.setMax(10000)
        self.addComponent(delay)

        # TODO icon select

        l = ShowListener(self, caption, description, style, position, delay)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
示例#15
0
    def __init__(self):
        super(NotificationHumanizedExample, self).__init__()

        self.setSpacing(True)
        self.setWidth(None)
        # layout will grow with content
        caption = TextField("Caption", "Document saved")
        caption.setWidth("200px")
        self.addComponent(caption)
        description = TextField("Description", "Invoices-2008.csv")
        description.setWidth("300px")
        self.addComponent(description)

        l = ShowListener(self, caption, description)
        show = Button("Show notification", l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
示例#16
0
    def __init__(self):
        super(NotificationHumanizedExample, self).__init__()

        self.setSpacing(True)
        self.setWidth(None)
        # layout will grow with content
        caption = TextField('Caption', 'Document saved')
        caption.setWidth('200px')
        self.addComponent(caption)
        description = TextField('Description', 'Invoices-2008.csv')
        description.setWidth('300px')
        self.addComponent(description)

        l = ShowListener(self, caption, description)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
 def createCoreHorizontal(self, recurse):
     l = HorizontalLayout()
     l.setSizeFull()
     tf = TextField('Top')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.TOP_LEFT)
     tf = TextField('Middle')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.MIDDLE_LEFT)
     tf = TextField('Bottom')
     l.addComponent(tf)
     tf.setWidth('50%')
     l.setComponentAlignment(tf, Alignment.BOTTOM_LEFT)
     if recurse > 0:
         recurse -= 1
         createCoreVertical = self.createCoreVertical(recurse)
         l.addComponent(createCoreVertical)
         l.setExpandRatio(createCoreVertical, 1)
     return l
示例#18
0
 def createCoreHorizontal(self, recurse):
     l = HorizontalLayout()
     l.setSizeFull()
     tf = TextField('Top')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.TOP_LEFT)
     tf = TextField('Middle')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.MIDDLE_LEFT)
     tf = TextField('Bottom')
     l.addComponent(tf)
     tf.setWidth('50%')
     l.setComponentAlignment(tf, Alignment.BOTTOM_LEFT)
     if recurse > 0:
         recurse -= 1
         createCoreVertical = self.createCoreVertical(recurse)
         l.addComponent(createCoreVertical)
         l.setExpandRatio(createCoreVertical, 1)
     return l
    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')
示例#20
0
    def __init__(self):
        super(NotificationWarningExample, self).__init__()

        self.setSpacing(True)

        self.setWidth(None)  # layout will grow with content

        caption = TextField('Caption', 'Upload canceled')
        caption.setWidth('200px')
        self.addComponent(caption)

        description = TextField('Description',
                'Invoices-2008.csv will not be processed')
        description.setWidth('300px')
        self.addComponent(description)

        l = ShowListener(self, caption, description)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
 def createCoreVertical(self, recurse):
     """Same with core layouts"""
     l = VerticalLayout()
     l.setSizeFull()
     tf = TextField('Left')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.TOP_LEFT)
     tf = TextField('Center')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.TOP_CENTER)
     tf = TextField('Right')
     l.addComponent(tf)
     tf.setWidth('50%')
     l.setComponentAlignment(tf, Alignment.TOP_RIGHT)
     if recurse > 0:
         recurse -= 1
         createCoreHorizontal = self.createCoreHorizontal(recurse)
         l.addComponent(createCoreHorizontal)
         l.setExpandRatio(createCoreHorizontal, 1)
     return l
示例#22
0
 def createCoreVertical(self, recurse):
     """Same with core layouts"""
     l = VerticalLayout()
     l.setSizeFull()
     tf = TextField('Left')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.TOP_LEFT)
     tf = TextField('Center')
     l.addComponent(tf)
     l.setComponentAlignment(tf, Alignment.TOP_CENTER)
     tf = TextField('Right')
     l.addComponent(tf)
     tf.setWidth('50%')
     l.setComponentAlignment(tf, Alignment.TOP_RIGHT)
     if recurse > 0:
         recurse -= 1
         createCoreHorizontal = self.createCoreHorizontal(recurse)
         l.addComponent(createCoreHorizontal)
         l.setExpandRatio(createCoreHorizontal, 1)
     return l
示例#23
0
    def __init__(self):
        super(NotificationTrayExample, self).__init__()

        self.setSpacing(True)

        self.setWidth(None)  # layout will grow with content

        caption = TextField('Caption', 'New message')
        caption.setWidth('200px')
        self.addComponent(caption)

        description = TextField('Description', '<b>John:</b> Could you '
                'upload Invoices-2008.csv so that...')
        description.setWidth('300px')
        self.addComponent(description)

        l = ShowListener(self, caption, description)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
    def __init__(self):
        super(NotificationErrorExample, self).__init__()

        self.setSpacing(True)

        self.setWidth(None)
        # layout will grow with content
        caption = TextField('Caption', 'Upload failed')
        caption.setWidth('200px')
        self.addComponent(caption)

        description = TextField('Description', 'Invoices-2008.csv could not '
                'be read.<br/>'
                'Perhaps the file is damaged, or in the wrong format?<br/>'
                'Try re-exporting and uploading the file again.')
        description.setWidth('300px')
        self.addComponent(description)

        l = ShowListener(self, caption, description)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
class PopupTextField(popup_view.IContent):
    def __init__(self):
        self._root = VerticalLayout()
        self._tf = TextField('Edit me')

        self._root.setSizeUndefined()
        self._root.setSpacing(True)
        self._root.setMargin(True)
        self._root.addComponent(
            Label(
                ('The changes made to any components '
                 'inside the popup are reflected automatically when the popup '
                 'is closed, but you might want to provide explicit action '
                 'buttons for the user, like \"Save\" or \"Close\".')))
        self._root.addComponent(self._tf)

        self._tf.setValue('Initial dynamic content')
        self._tf.setWidth('300px')

    def getMinimizedValueAsHTML(self):
        return str(self._tf.getValue())

    def getPopupComponent(self):
        return self._root
示例#26
0
    def __init__(self):
        super(HorizontalLayoutBasicExample, self).__init__()

        # First TextField
        tf = TextField()
        tf.setWidth('70px')
        self.addComponent(tf)

        # A dash
        dash = Label('-')
        self.addComponent(dash)
        self.setComponentAlignment(dash, Alignment.MIDDLE_LEFT)

        # Second TextField
        tf = TextField()
        tf.setWidth('70px')
        self.addComponent(tf)

        # Another dash
        dash = Label('-')
        self.addComponent(dash)
        self.setComponentAlignment(dash, Alignment.MIDDLE_LEFT)

        # Third TextField
        tf = TextField()
        tf.setWidth('70px')
        self.addComponent(tf)

        # Yet another dash
        dash = Label('-')
        self.addComponent(dash)
        self.setComponentAlignment(dash, Alignment.MIDDLE_LEFT)

        # Forth and last TextField
        tf = TextField()
        tf.setWidth('70px')
        self.addComponent(tf)