Example #1
0
    def __init__(self):
        super(CheckBoxesExample, self).__init__()

        self.setSpacing(True)

        # Button w/ text and tooltip
        cb = CheckBox(self._CAPTION)
        cb.setDescription(self._TOOLTIP)
        cb.setImmediate(True)
        cb.addListener(self, IClickListener)  # react to clicks
        self.addComponent(cb)

        # Button w/ text, icon and tooltip
        cb = CheckBox(self._CAPTION)
        cb.setDescription(self._TOOLTIP)
        cb.setIcon(self._ICON)
        cb.setImmediate(True)
        cb.addListener(self, IClickListener)  # react to clicks
        self.addComponent(cb)

        # Button w/ icon and tooltip
        cb = CheckBox()
        cb.setDescription(self._TOOLTIP)
        cb.setIcon(self._ICON)
        cb.setImmediate(True)
        cb.addListener(self, IClickListener)  # react to clicks
        self.addComponent(cb)
    def __init__(self):
        super(LayoutSpacingExample, self).__init__()

        # Create a grid layout.
        self.grid = GridLayout(3, 3)

        # Enable sp for the example layout (this is the one we'll toggle
        # with the checkbox)
        self.grid.setSpacing(False)

        # CheckBox for toggling sp on and off
        self.sp = CheckBox("Spacing enabled")
        #        self.sp.setValue(True)  # FIXME:
        self.sp.setImmediate(True)

        self.sp.addListener(self, IClickListener)
        self.addComponent(self.sp)

        # Add the layout to the containing layout.
        self.addComponent(self.grid)

        # Populate the layout with components.
        for i in range(9):
            self.grid.addComponent(Button('Component %d' % (i + 1)))

        self.setSpacing(True)  # enable sp for the example itself
Example #3
0
    def __init__(self):
        super(SubwindowCloseExample, self).__init__()

        self._closableWindow = CheckBox('Allow user to close the window', True)
        self._closableWindow.setImmediate(True)

        self._closableWindow.addListener(ClosableChangeListener(self),
                IValueChangeListener)

        # Create the window
        self._subwindow = Window('A subwindow w/ close-listener')

        self._subwindow.addListener(CloseListener(self), ICloseListener)

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

        # Add some content; a label and a close-button
        message = Label('This is a subwindow with a close-listener.')
        self._subwindow.addComponent(message)

        # Add a button for opening the subwindow
        self._openCloseButton = Button("Open window", ClickListener(self))

        self.setSpacing(True)
        self.addComponent(self._closableWindow)
        self.addComponent(self._openCloseButton)
Example #4
0
    def create(self, parent):
        """ Creates the underlying CheckBox widget.

        """
        self.widget = CheckBox()
        self.widget.setImmediate(True)
        parent.addComponent(self.widget)
    def __init__(self):
        super(SplitPanelBasicExample, self).__init__()

        # First a vertical SplitPanel
        vert = VerticalSplitPanel()
        vert.setHeight('450px')
        vert.setWidth('100%')
        vert.setSplitPosition(150, ISizeable.UNITS_PIXELS)
        self.addComponent(vert)

        # add a label to the upper area
        vert.addComponent(Label(self.brownFox))

        # Add a horizontal SplitPanel to the lower area
        horiz = HorizontalSplitPanel()
        horiz.setSplitPosition(50)  # percent
        vert.addComponent(horiz)

        # left component:
        horiz.addComponent(Label(self.brownFox))

        # right component:
        horiz.addComponent(Label(self.brownFox))

        # Lock toggle button
        toggleLocked = CheckBox('Splits locked', LockListener(vert, horiz))
        toggleLocked.setImmediate(True)
        self.addComponent(toggleLocked)
    def __init__(self):
        super(LayoutMarginExample, self).__init__(3, 3)

        self.setWidth('100%')
        self.setSpacing(True)

        self.addComponent(
            Label('Toggle layout margins with the checkboxes. '
                  'The right side margin has a theme-specified value, while '
                  'the other margins are the defaults.'), 0, 0, 2, 0)

        self.space()
        self._topMargin = CheckBox('Top', self)
        self._topMargin.setValue(True)
        self._topMargin.setImmediate(True)
        self.addComponent(self._topMargin)
        self.setComponentAlignment(self._topMargin, Alignment.TOP_CENTER)

        self.space()
        self._leftMargin = CheckBox('Left', self)
        self._leftMargin.setValue(True)
        self._leftMargin.setImmediate(True)
        self.addComponent(self._leftMargin)
        self.setComponentAlignment(self._leftMargin, Alignment.MIDDLE_LEFT)

        self._marginLayout = VerticalLayout()
        self._marginLayout.setStyleName('marginexample')
        self._marginLayout.setSizeUndefined()
        self._marginLayout.setMargin(True)
        self.addComponent(self._marginLayout)
        self._marginLayout.addComponent(Label('Margins all around?'))

        self._rightMargin = CheckBox('Right (100px)', self)
        self._rightMargin.setValue(True)
        self._rightMargin.setImmediate(True)
        self.addComponent(self._rightMargin)
        self.setComponentAlignment(self._rightMargin, Alignment.MIDDLE_LEFT)

        self.space()
        self._bottomMargin = CheckBox('Bottom', self)
        self._bottomMargin.setValue(True)
        self._bottomMargin.setImmediate(True)
        self.addComponent(self._bottomMargin)
        self.setComponentAlignment(self._bottomMargin, Alignment.TOP_CENTER)
    def __init__(self):
        super(UploadWithProgressMonitoringExample, self).__init__()

        self.setSpacing(True)

        self._state = Label()
        self._result = Label()
        self._fileName = Label()
        self._textualProgress = Label()
        self._pi = ProgressIndicator()
        self._counter = LineBreakCounter()
        self._upload = Upload(None, self._counter)

        self.addComponent(
            Label('Upload a file and we\'ll count the number '
                  'of line break characters (\\n) found in it.'))

        # make analyzing start immediatedly when file is selected
        self._upload.setImmediate(True)
        self._upload.setButtonCaption('Upload File')
        self.addComponent(self._upload)

        handBrake = CheckBox('Simulate slow server')
        handBrake.setValue(True)
        self._counter.setSlow(True)
        handBrake.setDescription(
            'Sleep for 100ms after each kilobyte to '
            'simulate slower processing/bandwidth. This is to show '
            'progress indicator even with rather small files.')
        handBrake.addListener(HandBrakeListener(self), button.IClickListener)

        cancelProcessing = Button('Cancel')
        cancelProcessing.addListener(CancelListener(self),
                                     button.IClickListener)
        cancelProcessing.setVisible(False)
        cancelProcessing.setStyleName('small')

        handBrake.setImmediate(True)
        self.addComponent(handBrake)

        p = Panel('Status')
        p.setSizeUndefined()

        l = FormLayout()
        l.setMargin(True)
        p.setContent(l)

        stateLayout = HorizontalLayout()
        stateLayout.setSpacing(True)
        stateLayout.addComponent(self._state)
        stateLayout.addComponent(cancelProcessing)
        stateLayout.setCaption('Current state')
        self._state.setValue('Idle')
        l.addComponent(stateLayout)

        self._fileName.setCaption('File name')
        l.addComponent(self._fileName)

        self._result.setCaption('Line breaks counted')
        l.addComponent(self._result)

        self._pi.setCaption('Progress')
        self._pi.setVisible(False)
        l.addComponent(self._pi)
        self._textualProgress.setVisible(False)
        l.addComponent(self._textualProgress)

        self.addComponent(p)

        self._upload.addListener(StartedListener(self),
                                 upload.IStartedListener)

        self._upload.addListener(ProgressListener(self),
                                 upload.IProgressListener)

        self._upload.addListener(SucceededListener(self),
                                 upload.ISucceededListener)

        self._upload.addListener(FailedListener(self), upload.IFailedListener)

        self._upload.addListener(FinishedListener(self),
                                 upload.IFinishedListener)