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

        self.addComponent(Label('Drag text from desktop application or '
                'image files from the ' + 'file system to the drop box '
                'below (dragging files requires HTML5 capable browser '
                'like FF 3.6, Safari or Chrome)'))

        dropPane = CssLayout()
        dropPane.setWidth('200px')
        dropPane.setHeight('200px')
        dropPane.addStyleName('image-drop-pane')

        dropBox = ImageDropBox(dropPane, self)
        dropBox.setSizeUndefined()

        panel = Panel(dropBox)
        panel.setSizeUndefined()
        panel.addStyleName('no-vertical-drag-hints')
        panel.addStyleName('no-horizontal-drag-hints')
        self.addComponent(panel)

        self._progress = ProgressIndicator()
        self._progress.setIndeterminate(True)
        self._progress.setVisible(False)
        self.addComponent(self._progress)
Esempio n. 2
0
    def __init__(self):
        super(DragDropHtml5FromDesktopExample, self).__init__()

        self.addComponent(
            Label('Drag text from desktop application or '
                  'image files from the ' + 'file system to the drop box '
                  'below (dragging files requires HTML5 capable browser '
                  'like FF 3.6, Safari or Chrome)'))

        dropPane = CssLayout()
        dropPane.setWidth('200px')
        dropPane.setHeight('200px')
        dropPane.addStyleName('image-drop-pane')

        dropBox = ImageDropBox(dropPane, self)
        dropBox.setSizeUndefined()

        panel = Panel(dropBox)
        panel.setSizeUndefined()
        panel.addStyleName('no-vertical-drag-hints')
        panel.addStyleName('no-horizontal-drag-hints')
        self.addComponent(panel)

        self._progress = ProgressIndicator()
        self._progress.setIndeterminate(True)
        self._progress.setVisible(False)
        self.addComponent(self._progress)
    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)
Esempio n. 4
0
    def __init__(self, group, ui, suppress_label=False):
        """Initialise the object.
        """
        # Get the contents of the group:
        content = group.get_content()

        # Save these for other methods.
        self.group = group
        self.ui = ui

        if group.orientation == 'horizontal':
            self.horizontal = True
        else:
            self.horizontal = False

        # outer is the top-level widget or layout that will eventually be
        # returned.  sub is the TabSheet or Accordion corresponding to any
        # 'tabbed' or 'fold' layout.  It is only used to collapse nested
        # widgets.  inner is the object (not necessarily a layout) that new
        # controls should be added to.
        outer = sub = inner = None

        # Get the group label.
        if suppress_label:
            label = ""
        else:
            label = group.label

        # Create a border if requested.
        if group.show_border:
            outer = Panel(label)
            if self.horizontal:
                inner = HorizontalLayout()
            else:
                inner = VerticalLayout()
            inner.setSizeUndefined()
            inner.addComponent(outer)

        elif label != "":
            if self.horizontal:
                outer = inner = HorizontalLayout()
            else:
                outer = inner = VerticalLayout()
            inner.setSizeUndefined()
            inner.addComponent(heading_text(None, text=label).control)

        # Add the layout specific content.
        if len(content) == 0:
            pass

        elif group.layout == 'flow':
            raise NotImplementedError, "the 'flow' layout isn't implemented"

        elif group.layout == 'split':
            # Create the splitter.
            splitter = _GroupSplitter(group)
            if self.horizontal:
                splitter.setOrientation(SplitPanel.ORIENTATION_HORIZONTAL)
            else:
                splitter.setOrientation(SplitPanel.ORIENTATION_VERTICAL)

            if outer is None:
                outer = splitter
            else:
                inner.addComponent(splitter)

            # Create an editor.
            editor = SplitterGroupEditor(control=outer, splitter=splitter,
                    ui=ui)
            self._setup_editor(group, editor)

            self._add_splitter_items(content, splitter)

        elif group.layout in ('tabbed', 'fold'):
            # Create the TabSheet or Accordion.
            if group.layout == 'tabbed':
                sub = TabSheet()
            else:
                sub = Accordion()

            _fill_panel(sub, content, self.ui, self._add_page_item)

            if outer is None:
                outer = sub
            else:
                inner.addComponent(sub)

            # Create an editor.
            editor = TabbedFoldGroupEditor(container=sub, control=outer, ui=ui)
            self._setup_editor(group, editor)

        else:
            # See if we need to control the visual appearence of the group.
            if group.visible_when != '' or group.enabled_when != '':
                # Make sure that outer is a widget or a layout.
                if outer is None:
                    outer = inner = HorizontalLayout()
                    outer.setSizeUndefined()

                # Create an editor.
                self._setup_editor(group, GroupEditor(control=outer))

            if isinstance(content[0], Group):
                layout = self._add_groups(content, inner)
            else:
                layout = self._add_items(content, inner)

#            for c in layout.getComponentIterator():
#                layout.setComponentAlignment(c, Alignment.TOP_LEFT)

            if outer is None:
                outer = layout
            elif layout is not inner:
                inner.addComponent(layout)

        # Publish the top-level widget, layout or None.
        self.control = outer

        # Publish the optional sub-control.
        self.sub_control = sub
    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)