Пример #1
0
    def _add_statusbar ( self ):
        """ Adds a statusbar to the dialog.
        """
        if self.ui.view.statusbar is not None:
            control = HorizontalLayout()
            control.setSizeGripEnabled(self.ui.view.resizable)
            listeners = []
            for item in self.ui.view.statusbar:
                # Create the status widget with initial text
                name = item.name
                item_control = Label()
                item_control.setValue(self.ui.get_extended_value(name))

                # Add the widget to the control with correct size
                width = abs(item.width)
                stretch = 0
                if width <= 1.0:
                    stretch = int(100 * width)
                else:
                    item_control.setWidth('%dpx' % width)
                control.addComponent(item_control)

                # Set up event listener for updating the status text
                col = name.find('.')
                obj = 'object'
                if col >= 0:
                    obj = name[:col]
                    name = name[col+1:]
                obj = self.ui.context[obj]
                set_text = self._set_status_text(item_control)
                obj.on_trait_change(set_text, name, dispatch='ui')
                listeners.append((obj, set_text, name))

            self.control.addComponent(control)
            self.ui._statusbar = listeners
    def __init__(self):
        super(PopupViewContentsExample, self).__init__()

        self.setSpacing(True)

        # ------
        # Static content for the minimized view
        # ------

        # Create the content for the popup
        content = Label('This is a simple Label component inside the popup. '
                        'You can place any Muntjac components here.')

        # The PopupView popup will be as large as needed by the content
        content.setWidth('300px')

        # Construct the PopupView with simple HTML text representing the
        # minimized view
        popup = PopupView('Static HTML content', content)
        self.addComponent(popup)

        # ------
        # Dynamic content for the minimized view
        # ------

        # In this sample we update the minimized view value with the content of
        # the TextField inside the popup.
        popup = PopupView(PopupTextField())
        popup.setDescription('Click to edit')
        popup.setHideOnMouseOut(False)
        self.addComponent(popup)
Пример #3
0
class TextAreaExample(HorizontalLayout, IValueChangeListener):

    _initialText = 'The quick brown fox jumps over the lazy dog.'

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

        self.setSpacing(True)

        self.setWidth('100%')

        self._editor = TextArea(None, self._initialText)
        self._editor.setRows(20)
        self._editor.setColumns(20)
        self._editor.addListener(self, IValueChangeListener)
        self._editor.setImmediate(True)
        self.addComponent(self._editor)

        # the TextArea is immediate, and it's valueCahnge updates the Label,
        # so this button actually does nothing
        self.addComponent(Button('>'))
        self._plainText = Label(self._initialText)
        self._plainText.setContentMode(Label.CONTENT_XHTML)
        self.addComponent(self._plainText)
        self.setExpandRatio(self._plainText, 1)

    # Catch the valuechange event of the textfield and update the value of the
    # label component
    def valueChange(self, event):
        text = self._editor.getValue()
        if text is not None:
            # replace newline with BR, because we're using Label.CONTENT_XHTML
            text = text.replace('\n', '<br/>')
        self._plainText.setValue(text)
Пример #4
0
    def init(self):
        main = Window("CSS Tools Add-on Test")
        self.setMainWindow(main)

        testWindow = Window("Normal Window")
        testWindow.addComponent(Label("<p>This window is used as the component to measure.</p>", Label.CONTENT_XHTML))
        main.addWindow(testWindow)
        testWindow.center()

        title = Label("CSS Properties to Retrieve")
        title.addStyleName(Reindeer.LABEL_H2)
        main.addComponent(title)

        target = NativeSelect("Target Component")
        main.addComponent(target)

        get = Button("Refresh Properties", GetClickListener(self, target))
        main.addComponent(get)

        main.addComponent(self.buildLabels())

        target.addItem(main.getContent())
        target.setItemCaption(main.getContent(), "Root layout")
        target.addItem(testWindow)
        target.setItemCaption(testWindow, "Sub window")
        target.addItem(get)
        target.setItemCaption(get, "The '" + get.getCaption() + "' Button")
        target.setNullSelectionAllowed(False)
        target.select(testWindow)
    def __init__(self):
        super(AccordionDisabledExample, self).__init__()

        self.setSpacing(True)

        self._l1 = Label('There are no previously saved actions.')
        self._l2 = Label('There are no saved notes.')
        self._l3 = Label('There are currently no issues.')

        self._a = Accordion()
        self._a.setHeight('300px')
        self._a.setWidth('400px')
        self._t1 = self._a.addTab(self._l1, 'Saved actions', self._icon1)
        self._t2 = self._a.addTab(self._l2, 'Notes', self._icon2)
        self._t3 = self._a.addTab(self._l3, 'Issues', self._icon3)
        self._a.addListener(self, tab_sheet.ISelectedTabChangeListener)

        self._b1 = Button('Disable \'Notes\' tab')
        self._b2 = Button('Hide \'Issues\' tab')
        self._b1.addListener(self, button.IClickListener)
        self._b2.addListener(self, button.IClickListener)

        hl = HorizontalLayout()
        hl.setSpacing(True)
        hl.addComponent(self._b1)
        hl.addComponent(self._b2)

        self.addComponent(self._a)
        self.addComponent(hl)
Пример #6
0
    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)
Пример #7
0
    def __init__(self):
        super(TabSheetIconsExample, self).__init__()

        # Tab 1 content
        l1 = VerticalLayout()
        l1.setMargin(True)
        l1.addComponent(Label('There are no previously saved actions.'))

        # Tab 2 content
        l2 = VerticalLayout()
        l2.setMargin(True)
        l2.addComponent(Label('There are no saved notes.'))

        # Tab 3 content
        l3 = VerticalLayout()
        l3.setMargin(True)
        l3.addComponent(Label('There are currently no issues.'))

        self._t = TabSheet()
        self._t.setHeight('200px')
        self._t.setWidth('400px')
        self._t.addTab(l1, 'Saved actions', self._icon1)
        self._t.addTab(l2, 'Notes', self._icon2)
        self._t.addTab(l3, 'Issues', self._icon3)
        self._t.addListener(self, ISelectedTabChangeListener)

        self.addComponent(self._t)
Пример #8
0
    def init(self):
        main = Window('CSS Tools Add-on Test')
        self.setMainWindow(main)

        testWindow = Window('Normal Window')
        testWindow.addComponent(
            Label("<p>This window is used as the component to measure.</p>",
                  Label.CONTENT_XHTML))
        main.addWindow(testWindow)
        testWindow.center()

        title = Label('CSS Properties to Retrieve')
        title.addStyleName(Reindeer.LABEL_H2)
        main.addComponent(title)

        target = NativeSelect('Target Component')
        main.addComponent(target)

        get = Button('Refresh Properties', GetClickListener(self, target))
        main.addComponent(get)

        main.addComponent(self.buildLabels())

        target.addItem(main.getContent())
        target.setItemCaption(main.getContent(), 'Root layout')
        target.addItem(testWindow)
        target.setItemCaption(testWindow, 'Sub window')
        target.addItem(get)
        target.setItemCaption(get, 'The \'' + get.getCaption() + '\' Button')
        target.setNullSelectionAllowed(False)
        target.select(testWindow)
Пример #9
0
    def __init__(self):
        super(WebLayoutWindow, self).__init__()

        # Our main layout is a horizontal layout
        main = HorizontalLayout()
        main.setMargin(True)
        main.setSpacing(True)
        self.setContent(main)

        # Tree to the left
        tree = Tree()
        tree.setContainerDataSource( ExampleUtil.getHardwareContainer() )
        tree.setItemCaptionPropertyId( ExampleUtil.hw_PROPERTY_NAME )
        for idd in tree.rootItemIds():
            tree.expandItemsRecursively(idd)
        self.addComponent(tree)

        # vertically divide the right area
        left = VerticalLayout()
        left.setSpacing(True)
        self.addComponent(left)

        # table on top
        tbl = Table()
        tbl.setWidth('500px')
        tbl.setContainerDataSource( ExampleUtil.getISO3166Container() )
        tbl.setSortDisabled(True)
        tbl.setPageLength(7)
        left.addComponent(tbl)

        # Label on bottom
        text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML)
        text.setWidth('500px')  # some limit is good for text
        left.addComponent(text)
    def createComponents(self):
        components = list()

        label = Label('This is a long text block that will wrap.')
        label.setWidth('120px')
        components.append(label)

        image = Embedded('', ThemeResource('../runo/icons/64/document.png'))
        components.append(image)

        documentLayout = CssLayout()
        documentLayout.setWidth('19px')
        for _ in range(5):
            e = Embedded(None, ThemeResource('../runo/icons/16/document.png'))
            e.setHeight('16px')
            e.setWidth('16px')
            documentLayout.addComponent(e)
        components.append(documentLayout)

        buttonLayout = VerticalLayout()
        button = Button('Button')

        button.addListener(ButtonClickListener(self), IClickListener)
        buttonLayout.addComponent(button)
        buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER)
        components.append(buttonLayout)

        return components
Пример #11
0
class LabelRichExample(VerticalLayout, IClickListener):

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

        self.setSpacing(True)

        self._editor = RichTextArea()
        self._richText = Label('<h1>Rich text example</h1>'
                '<p>The <b>quick</b> brown fox jumps <sup>over</sup> '
                'the <b>lazy</b> dog.</p>'
                '<p>This text can be edited with the <i>Edit</i> -button</p>')
        self._richText.setContentMode(Label.CONTENT_XHTML)
        self.addComponent(self._richText)

        self._b = Button('Edit')
        self._b.addListener(self, IClickListener)
        self.addComponent(self._b)

        self._editor.setWidth('100%')


    def buttonClick(self, event):
        if self.getComponentIterator().next() == self._richText:
            self._editor.setValue(self._richText.getValue())
            self.replaceComponent(self._richText, self._editor)
            self._b.setCaption('Apply')
        else:
            self._richText.setValue(self._editor.getValue())
            self.replaceComponent(self._editor, self._richText)
            self._b.setCaption('Edit')
Пример #12
0
class LabelRichExample(VerticalLayout, IClickListener):
    def __init__(self):
        super(LabelRichExample, self).__init__()

        self.setSpacing(True)

        self._editor = RichTextArea()
        self._richText = Label(
            '<h1>Rich text example</h1>'
            '<p>The <b>quick</b> brown fox jumps <sup>over</sup> '
            'the <b>lazy</b> dog.</p>'
            '<p>This text can be edited with the <i>Edit</i> -button</p>')
        self._richText.setContentMode(Label.CONTENT_XHTML)
        self.addComponent(self._richText)

        self._b = Button('Edit')
        self._b.addListener(self, IClickListener)
        self.addComponent(self._b)

        self._editor.setWidth('100%')

    def buttonClick(self, event):
        if self.getComponentIterator().next() == self._richText:
            self._editor.setValue(self._richText.getValue())
            self.replaceComponent(self._richText, self._editor)
            self._b.setCaption('Apply')
        else:
            self._richText.setValue(self._editor.getValue())
            self.replaceComponent(self._editor, self._richText)
            self._b.setCaption('Edit')
Пример #13
0
    def create(self, parent):
        """ Creates the underlying widget to display HTML.

        """
        self.widget = Label()
        self.widget.setContentMode(Label.CONTENT_XHTML)
        parent.addComponent(self.widget)
Пример #14
0
    def __init__(self):
        super(WebLayoutWindow, self).__init__()

        # Our main layout is a horizontal layout
        main = HorizontalLayout()
        main.setMargin(True)
        main.setSpacing(True)
        self.setContent(main)

        # Tree to the left
        tree = Tree()
        tree.setContainerDataSource(ExampleUtil.getHardwareContainer())
        tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME)
        for idd in tree.rootItemIds():
            tree.expandItemsRecursively(idd)
        self.addComponent(tree)

        # vertically divide the right area
        left = VerticalLayout()
        left.setSpacing(True)
        self.addComponent(left)

        # table on top
        tbl = Table()
        tbl.setWidth('500px')
        tbl.setContainerDataSource(ExampleUtil.getISO3166Container())
        tbl.setSortDisabled(True)
        tbl.setPageLength(7)
        left.addComponent(tbl)

        # Label on bottom
        text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML)
        text.setWidth('500px')  # some limit is good for text
        left.addComponent(text)
Пример #15
0
    def __init__(self):
        super(PopupViewContentsExample, self).__init__()

        self.setSpacing(True)

        # ------
        # Static content for the minimized view
        # ------

        # Create the content for the popup
        content = Label('This is a simple Label component inside the popup. '
                'You can place any Muntjac components here.')

        # The PopupView popup will be as large as needed by the content
        content.setWidth('300px')

        # Construct the PopupView with simple HTML text representing the
        # minimized view
        popup = PopupView('Static HTML content', content)
        self.addComponent(popup)

        # ------
        # Dynamic content for the minimized view
        # ------

        # In this sample we update the minimized view value with the content of
        # the TextField inside the popup.
        popup = PopupView( PopupTextField() )
        popup.setDescription('Click to edit')
        popup.setHideOnMouseOut(False)
        self.addComponent(popup)
Пример #16
0
    def __init__(self):
        super(ButtonPushExample, self).__init__()

        # Normal buttons (more themable)
        buttons = VerticalLayout()
        buttons.setSpacing(True)
        buttons.setMargin(False, True, False, False)
        self.addComponent(buttons)
        buttons.addComponent(Label("<h3>Normal buttons</h3>",
                Label.CONTENT_XHTML))

        # Button w/ text and tooltip
        b = Button(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

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

        # Button w/ icon and tooltip
        b = Button()
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # NativeButtons
        buttons = VerticalLayout()
        buttons.setSpacing(True)
        buttons.setMargin(False, False, False, True)
        self.addComponent(buttons)
        buttons.addComponent(Label("<h3>Native buttons</h3>",
                Label.CONTENT_XHTML));

        # NativeButton w/ text and tooltip
        b = NativeButton(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # NativeButton w/ text, icon and tooltip
        b = NativeButton(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # NativeButton w/ icon and tooltip
        b = NativeButton()
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)
    def attach(self):
        if self._populated:
            return  # Only populate the layout once

        # Find the context we are running in and get the browser information
        # from that.
        context = self.getApplication().getContext()
        webBrowser = context.getBrowser()

        # Create a text to show based on the browser.
        browserText = self.getBrowserAndVersion(webBrowser)
        browserText = browserText + ' in ' + self.getOperatingSystem(
            webBrowser)

        # Create labels for the information and add them to the application
        ipAddresslabel = Label(
            "Hello user from <b>" + webBrowser.getAddress() + "</b>.",
            Label.CONTENT_XHTML)
        browser = Label("You are running <b>" + browserText + "</b>.",
                        Label.CONTENT_XHTML)
        screenSize = Label(
            "Your screen resolution is <b>" +
            str(webBrowser.getScreenWidth()) + "x" +
            str(webBrowser.getScreenHeight()) + "</b>.", Label.CONTENT_XHTML)
        locale = Label(
            "Your browser is set to primarily use the <b>" +
            str(webBrowser.getLocale()) + "</b> locale.", Label.CONTENT_XHTML)

        # FIXME: timezones
        #        timeZones = NativeSelect()
        #        # Client timezone offset w/o possible DST:
        #        rtzOffset = webBrowser.getRawTimezoneOffset()
        #        # DST:
        #        dst = webBrowser.getDSTSavings()
        #        # use raw offset to get possible TZ:
        #        tzs = TimeZone.getAvailableIDs(rtzOffset)
        #        for idd in tzs:
        #            tz = TimeZone.getTimeZone(idd)
        #            if dst == tz.getDSTSavings():
        #                # only include zones w/ DST if we know we have DST
        #                caption = idd + ' (' + tz.getDisplayName() + ')'
        #                timeZones.addItem(caption)
        #                if timeZones.getValue() is None:
        #                    # select first
        #                    timeZones.setValue(caption)
        #
        #        timeZones.setImmediate(True)
        #        timeZones.setNullSelectionAllowed(False)
        #        timeZones.setCaption(self.getTimeZoneInfoString(webBrowser))

        self.addComponent(ipAddresslabel)
        self.addComponent(browser)
        self.addComponent(screenSize)
        self.addComponent(locale)
        #        self.addComponent(timeZones)

        self._populated = True
Пример #18
0
class JSApiExample(VerticalLayout):

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

        self._toBeUpdatedFromThread = None
        self._startThread = None
        self._running = Label('')

        self.setSpacing(True)

        javascript = Label("<h3>Run Native JavaScript</h3>",
                Label.CONTENT_XHTML)
        self.addComponent(javascript)

        script = TextArea()
        script.setWidth('100%')
        script.setRows(3)
        script.setValue('alert(\"Hello Muntjac\");')
        self.addComponent(script)

        self.addComponent(Button('Run script', RunListener(self, script)))
        sync = Label("<h3>Force Server Syncronization</h3>",
                Label.CONTENT_XHTML)
        self.addComponent(sync)

        self.addComponent(Label('For advanced client side programmers '
                'Muntjac offers a simple method which can be used to force '
                'the client to synchronize with the server. This may be '
                'needed for example if another part of a mashup changes '
                'things on server.'))

        self._toBeUpdatedFromThread = Label("This Label component will be "
                "updated by a background thread. Click \"Start "
                "background thread\" button and start clicking "
                "on the link below to force "
                "synchronization.", Label.CONTENT_XHTML)
        self.addComponent(self._toBeUpdatedFromThread)

        # This label will be show for 10 seconds while the background process
        # is working
        self._running.setCaption('Background process is running for 10 '
                'seconds, click the link below')
        self._running.setIcon(
                ThemeResource('../base/common/img/ajax-loader-medium.gif'))

        # Clicking on this button will start a repeating thread that updates
        # the label value
        self._startThread = Button('Start background thread',
                StartListener(self))
        self.addComponent(self._startThread)

        # This link will make an Ajax request to the server that will respond
        # with UI changes that have happened since last request
        self.addComponent(Label("<a href=\"javascript:vaadin.forceSync();\">"
                "javascript: vaadin.forceSync();</a>", Label.CONTENT_XHTML))
Пример #19
0
    def __init__(self):
        super(Calc, self).__init__()

        # All variables are automatically stored in the session.
        self._current = 0.0
        self._stored = 0.0
        self._lastOperationRequested = 'C'

        # User interface components
        self._display = Label('0.0')
Пример #20
0
    def __init__(self):
        super(FeatureView, self).__init__()

        self._right = None
        self._left = None
        self._controls = None
        self._title = Label("", Label.CONTENT_XHTML)
        self._showSrc = None
        self._exampleCache = dict()
        self._currentFeature = None
        self._srcWindow = None

        self.setWidth('100%')
        self.setMargin(True)
        self.setSpacing(True)
        self.setStyleName('sample-view')

        self._left = VerticalLayout()
        self._left.setWidth('100%')
        self._left.setSpacing(True)
        self._left.setMargin(False)
        self.addComponent(self._left)
        self.setExpandRatio(self._left, 1)

        rightLayout = VerticalLayout()
        self._right = Panel(rightLayout)
        rightLayout.setMargin(True, False, False, False)
        self._right.setStyleName(Reindeer.PANEL_LIGHT)
        self._right.addStyleName('feature-info')
        self._right.setWidth('319px')
        self.addComponent(self._right)

        self._controls = HorizontalLayout()
        self._controls.setWidth('100%')
        self._controls.setStyleName('feature-controls')

        self._title.setStyleName('title')
        self._controls.addComponent(self._title)
        self._controls.setExpandRatio(self._title, 1)

        resetExample = NativeButton('Reset', ResetListener(self))
        resetExample.setStyleName(BaseTheme.BUTTON_LINK)
        resetExample.addStyleName('reset')
        resetExample.setDescription('Reset Sample')
        self._controls.addComponent(resetExample)
        self._showSrc = ActiveLink()
        self._showSrc.setDescription(
            'Right / middle / ctrl / shift -click for browser window/tab')

        self._showSrc.addListener(ShowSrcListener(self),
                                  ILinkActivatedListener)
        self._showSrc.setCaption(self._MSG_SHOW_SRC)
        self._showSrc.addStyleName('showcode')
        self._showSrc.setTargetBorder(Link.TARGET_BORDER_NONE)
        self._controls.addComponent(self._showSrc)
Пример #21
0
class Calc2(Application, IClickListener):
    """A simple calculator using Muntjac."""

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

        # All variables are automatically stored in the session.
        self._current = 0.0
        self._stored = 0.0
        self._lastOperationRequested = 'C'

        self.pure_calc = PureCalc()

        # User interface components
        self._display = Label('0.0')


    def init(self):

        layout = GridLayout(4, 5)

        self.setMainWindow(Window('Calculator Application', layout))

        layout.addComponent(self._display, 0, 0, 3, 0)

        operations = ['7', '8', '9', '/', '4', '5', '6',
                '*', '1', '2', '3', '-', '0', '=', 'C', '+']

        for caption in operations:
            # Create a button and use this application for event handling
            button = Button(caption)
            button.addListener(self)

            # Add the button to our main layout
            layout.addComponent(button)


    def buttonClick(self, event):
        # Event handler for button clicks. Called for all the buttons in
        # the application.

        # Get the button that was clicked
        button = event.getButton()

        # Get the requested operation from the button caption
        requestedOperation = button.getCaption()[0]

        self.pure_calc.proc_char(requestedOperation)
        if self.pure_calc.digit_operation(requestedOperation):
            newValue = self.pure_calc._current
        else:
            newValue = self.pure_calc._stored

        # Update the result label with the new value
        self._display.setValue(newValue)
Пример #22
0
 def buildLabels(self):
     grid = GridLayout()
     grid.setSpacing(True)
     grid.setWidth("100%")
     grid.setColumns(6)
     for prop in CssProperty.values():
         l = Label("-")
         l.setSizeUndefined()
         l.setCaption(str(prop))
         self._props[prop] = l
         grid.addComponent(l)
     return grid
Пример #23
0
    def __init__(self):
        super(LabelPlainExample, self).__init__()

        self.setSpacing(True)

        plainText = Label('This is an example of a Label'
                ' component. The content mode of this label is set'
                ' to CONTENT_TEXT. This means that it will display'
                ' the content text as is. HTML and XML special characters'
                ' (<,>,&) are escaped properly to allow displaying them.')
        plainText.setContentMode(Label.CONTENT_TEXT)
        self.addComponent(plainText)
Пример #24
0
    def init(self):
#        super(GoogleMapWidgetApp, self).__init__()

        self.setMainWindow(Window('Google Map add-on demo'))

        # Create a new map instance centered on the IT Mill offices
        self._googleMap = GoogleMap(self, (22.3, 60.4522), 8)

        self._googleMap.setWidth('640px')
        self._googleMap.setHeight('480px')

        # Create a marker at the IT Mill offices
        self._mark1 = BasicMarker(1L, (22.3, 60.4522), 'Test marker 1')
        self._mark2 = BasicMarker(2L, (22.4, 60.4522), 'Test marker 2')
        self._mark3 = BasicMarker(4L, (22.6, 60.4522), 'Test marker 3')
        self._mark4 = BasicMarker(5L, (22.7, 60.4522), 'Test marker 4')

        l = MarkerClickListener(self)
        self._googleMap.addListener(l, IMarkerClickListener)

        # Marker with information window pupup
        self._mark5 = BasicMarker(6L, (22.8, 60.4522), 'Marker 5')
        self._mark5.setInfoWindowContent(self._googleMap,
                Label('Hello Marker 5!'))

        content = Label('Hello Marker 2!')
        content.setWidth('60px')
        self._mark2.setInfoWindowContent(self._googleMap, content)

        self._googleMap.addMarker(self._mark1)
        self._googleMap.addMarker(self._mark2)
        self._googleMap.addMarker(self._mark3)
        self._googleMap.addMarker(self._mark4)
        self._googleMap.addMarker(self._mark5)
        self.getMainWindow().getContent().addComponent(self._googleMap)

        # Add a Marker click listener to catch marker click events.
        # Note, works only if marker has information window content
        l = MarkerClickListener2(self)
        self._googleMap.addListener(l, IMarkerClickListener)

        # Add a MarkerMovedListener to catch events when a marker is dragged to
        # a new location
        l = MarkerMovedListener(self)
        self._googleMap.addListener(l, IMarkerMovedListener)

        l = MapMoveListener(self)
        self._googleMap.addListener(l, IMapMoveListener)

        self._googleMap.addControl(MapControl.MapTypeControl)

        self.addTestButtons()  # Add buttons that trigger tests map features
Пример #25
0
    def init(self):
        #        super(GoogleMapWidgetApp, self).__init__()

        self.setMainWindow(Window('Google Map add-on demo'))

        # Create a new map instance centered on the IT Mill offices
        self._googleMap = GoogleMap(self, (22.3, 60.4522), 8)

        self._googleMap.setWidth('640px')
        self._googleMap.setHeight('480px')

        # Create a marker at the IT Mill offices
        self._mark1 = BasicMarker(1L, (22.3, 60.4522), 'Test marker 1')
        self._mark2 = BasicMarker(2L, (22.4, 60.4522), 'Test marker 2')
        self._mark3 = BasicMarker(4L, (22.6, 60.4522), 'Test marker 3')
        self._mark4 = BasicMarker(5L, (22.7, 60.4522), 'Test marker 4')

        l = MarkerClickListener(self)
        self._googleMap.addListener(l, IMarkerClickListener)

        # Marker with information window pupup
        self._mark5 = BasicMarker(6L, (22.8, 60.4522), 'Marker 5')
        self._mark5.setInfoWindowContent(self._googleMap,
                                         Label('Hello Marker 5!'))

        content = Label('Hello Marker 2!')
        content.setWidth('60px')
        self._mark2.setInfoWindowContent(self._googleMap, content)

        self._googleMap.addMarker(self._mark1)
        self._googleMap.addMarker(self._mark2)
        self._googleMap.addMarker(self._mark3)
        self._googleMap.addMarker(self._mark4)
        self._googleMap.addMarker(self._mark5)
        self.getMainWindow().getContent().addComponent(self._googleMap)

        # Add a Marker click listener to catch marker click events.
        # Note, works only if marker has information window content
        l = MarkerClickListener2(self)
        self._googleMap.addListener(l, IMarkerClickListener)

        # Add a MarkerMovedListener to catch events when a marker is dragged to
        # a new location
        l = MarkerMovedListener(self)
        self._googleMap.addListener(l, IMarkerMovedListener)

        l = MapMoveListener(self)
        self._googleMap.addListener(l, IMapMoveListener)

        self._googleMap.addControl(MapControl.MapTypeControl)

        self.addTestButtons()  # Add buttons that trigger tests map features
Пример #26
0
    def __init__(self):
        super(LabelPlainExample, self).__init__()

        self.setSpacing(True)

        plainText = Label(
            'This is an example of a Label'
            ' component. The content mode of this label is set'
            ' to CONTENT_TEXT. This means that it will display'
            ' the content text as is. HTML and XML special characters'
            ' (<,>,&) are escaped properly to allow displaying them.')
        plainText.setContentMode(Label.CONTENT_TEXT)
        self.addComponent(plainText)
Пример #27
0
    def __init__(self):
        super(TabSheetClosingExample, self).__init__()

        # Tab 1 content
        l1 = VerticalLayout()
        l1.setMargin(True)
        l1.addComponent(Label('There are no previously saved actions.'))

        # Tab 2 content
        l2 = VerticalLayout()
        l2.setMargin(True)
        l2.addComponent(Label('There are no saved notes.'))

        # Tab 3 content
        l3 = VerticalLayout()
        l3.setMargin(True)
        l3.addComponent(Label('There are currently no issues.'))

        # Tab 4 content
        l4 = VerticalLayout()
        l4.setMargin(True)
        l4.addComponent(Label('There are no comments.'))

        # Tab 5 content
        l5 = VerticalLayout()
        l5.setMargin(True)
        l5.addComponent(Label('There is no new feedback.'))

        self._t = TabSheet()
        self._t.setHeight('200px')
        self._t.setWidth('400px')

        saved = self._t.addTab(l1, 'Saved actions', None)
        saved.setClosable(True)

        notes = self._t.addTab(l2, 'Notes', None)
        notes.setClosable(True)

        issues = self._t.addTab(l3, 'Issues', None)
        issues.setClosable(True)

        comments = self._t.addTab(l4, 'Comments', None)
        comments.setClosable(True)

        feedback = self._t.addTab(l5, 'Feedback', None)
        feedback.setClosable(True)

        self._t.addListener(self, tab_sheet.ISelectedTabChangeListener)
        self._t.setCloseHandler(self)

        self.addComponent(self._t)
Пример #28
0
 def __init__(self):
     super(LabelPreformattedExample, self).__init__()
     self.setSpacing(True)
     preformattedText = Label('This is an example of a Label component.\n'
                              '\nThe content mode of this label is set'
                              '\nto CONTENT_PREFORMATTED. This means'
                              '\nthat it will display the content text'
                              '\nusing a fixed-width font. You also have'
                              '\nto insert the line breaks yourself.\n'
                              '\n\tHTML and XML special characters'
                              '\n\t(<,>,&) are escaped properly to'
                              '\n\tallow displaying them.')
     preformattedText.setContentMode(Label.CONTENT_PREFORMATTED)
     self.addComponent(preformattedText)
Пример #29
0
 def __init__(self):
     super(LabelPreformattedExample, self).__init__()
     self.setSpacing(True)
     preformattedText = Label('This is an example of a Label component.\n'
             '\nThe content mode of this label is set'
             '\nto CONTENT_PREFORMATTED. This means'
             '\nthat it will display the content text'
             '\nusing a fixed-width font. You also have'
             '\nto insert the line breaks yourself.\n'
             '\n\tHTML and XML special characters'
             '\n\t(<,>,&) are escaped properly to'
             '\n\tallow displaying them.')
     preformattedText.setContentMode(Label.CONTENT_PREFORMATTED)
     self.addComponent(preformattedText)
Пример #30
0
    def __init__(self):
        super(PackageIconsExample, self).__init__()

        self._icons = ['arrow-down.png', 'arrow-left.png', 'arrow-right.png',
            'arrow-up.png', 'attention.png', 'calendar.png', 'cancel.png',
            'document.png', 'document-add.png', 'document-delete.png',
            'document-doc.png', 'document-image.png', 'document-pdf.png',
            'document-ppt.png', 'document-txt.png', 'document-web.png',
            'document-xsl.png', 'email.png', 'email-reply.png',
            'email-send.png', 'folder.png', 'folder-add.png',
            'folder-delete.png', 'globe.png', 'help.png', 'lock.png',
            'note.png', 'ok.png', 'reload.png', 'settings.png', 'trash.png',
            'trash-full.png', 'user.png', 'users.png']

        self._sizes = ['16', '32', '64']

        self.setSpacing(True)

        tabSheet = TabSheet()
        tabSheet.setStyleName(Reindeer.TABSHEET_MINIMAL)

        for size in self._sizes:
            iconsSideBySide = 2 if size == '64' else 3
            grid = GridLayout(iconsSideBySide * 2, 1)
            grid.setSpacing(True)
            grid.setMargin(True)
            tabSheet.addTab(grid, size + 'x' + size, None)

            tabSheet.addComponent(grid)
            for icon in self._icons:
                res = ThemeResource('../runo/icons/' + size + '/' + icon)

                e = Embedded(None, res)

                # Set size to avoid flickering when loading
                e.setWidth(size + 'px')
                e.setHeight(size + 'px')

                name = Label(icon)
                if size == '64':
                    name.setWidth('185px')
                else:
                    name.setWidth('150px')

                grid.addComponent(e)
                grid.addComponent(name)

                grid.setComponentAlignment(name, Alignment.MIDDLE_LEFT)

        self.addComponent(tabSheet)
Пример #31
0
    def resynch_editor ( self ):
        """ Resynchronizes the contents of the editor when the object trait
        changes externally to the editor.
        """
        panel = self._panel
        if panel is not None:
            # Dispose of the previous contents of the panel:
            layout = panel.getParent()
            if layout is None:
                layout = VerticalLayout()
                panel.addComponent(layout)
#                layout.setParent(panel)
                layout.setMargin(False)
            elif self._ui is not None:
                self._ui.dispose()
                self._ui = None
            else:
                layout.removeAllComponents()

            # Create the new content for the panel:
            stretch = 0
            value   = self.value
            if not isinstance( value, HasTraits ):
                str_value = ''
                if value is not None:
                    str_value = self.str_value
                control = Label()
                control.setValue(str_value)
            else:
                view    = self.view_for( value, self.item_for( value ) )
                context = value.trait_context()
                handler = None
                if isinstance( value, Handler ):
                    handler = value
                context.setdefault( 'context', self.object )
                context.setdefault( 'context_handler', self.ui.handler )
                self._ui = ui = view.ui( context, panel, 'subpanel',
                                         value.trait_view_elements(), handler,
                                         self.factory.id )
                control         = ui.control
                self.scrollable = ui._scrollable
                ui.parent       = self.ui

                if view.resizable or view.scrollable or ui._scrollable:
                    stretch = 1

            # FIXME: Handle stretch.
            layout.addComponent(control)
Пример #32
0
 def valueChange(self, event):
     tf = event.getProperty()
     tf.validate()
     if tf.getValue() is not None:
         self._component._usernames.add(str(tf.getValue()))
         self.addComponent(Label('Added ' + tf.getValue() +
                                 ' to usernames'))
Пример #33
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)
Пример #34
0
    def __init__(self):
        super(SubwindowExample, self).__init__()

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

        # Configure the windows 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')
        self._subwindow.addComponent(message)

        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.TOP_RIGHT)

        # Add a button for opening the subwindow
        opn = Button('Open subwindow', OpenListener(self))
        self.addComponent(opn)
Пример #35
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)
Пример #36
0
    def __init__(self):
        super(PanelLightExample, self).__init__()

        self.setSpacing(True)
        self.setSpacing(True)

        # Panel 1 - with caption
        self._panel = Panel('This is a light Panel')
        self._panel.setStyleName(Reindeer.PANEL_LIGHT)
        self._panel.setHeight('200px')  # we want scrollbars
        # let's adjust the panels default layout (a VerticalLayout)
        layout = self._panel.getContent()
        layout.setMargin(True)  # we want a margin
        layout.setSpacing(True)
        # and spacing between components
        self.addComponent(self._panel)

        # Let's add a few rows to provoke scrollbars:
        for _ in range(20):
            l = Label('The quick brown fox jumps over the lazy dog.')
            self._panel.addComponent(l)

        # Caption toggle:
        b = Button('Toggle caption')
        b.addListener(self, IClickListener)
        self.addComponent(b)
Пример #37
0
    def __init__(self):
        super(OptionGroupsExample, self).__init__()

        self.setSpacing(True)

        # 'Shorthand' constructor - also supports data binding using Containers
        citySelect = OptionGroup('Please select a city', self._cities)
        # user can not 'unselect'
        citySelect.setNullSelectionAllowed(False)
        # select this by default
        citySelect.select('Berlin')
        # send the change to the server at once
        citySelect.setImmediate(True)
        # react when the user selects something
        citySelect.addListener(self, IValueChangeListener)
        self.addComponent(citySelect)

        self.addComponent(
            Label('<h3>Multi-selection</h3>', Label.CONTENT_XHTML))

        # Create the multiselect option group
        # 'Shorthand' constructor - also supports data binding using Containers
        citySelect = OptionGroup('Please select cities', self._cities)
        citySelect.setMultiSelect(True)  # FIXME: multi-select
        # user can not 'unselect'
        citySelect.setNullSelectionAllowed(False)
        # select this by default
        citySelect.select('Berlin')
        # send the change to the server at once
        citySelect.setImmediate(True)
        # react when the user selects something
        citySelect.addListener(self, IValueChangeListener)
        self.addComponent(citySelect)
Пример #38
0
    def __init__(self):
        super(ApplicationLayoutWindow, self).__init__()

        # Our main layout is a horizontal layout
        main = HorizontalLayout()
        main.setSizeFull()
        self.setContent(main)

        # Tree to the left
        treePanel = Panel()  # for scrollbars
        treePanel.setStyleName(Reindeer.PANEL_LIGHT)
        treePanel.setHeight('100%')
        treePanel.setWidth(None)
        treePanel.getContent().setSizeUndefined()
        self.addComponent(treePanel)

        tree = Tree()
        tree.setContainerDataSource(ExampleUtil.getHardwareContainer())
        tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME)
        for idd in tree.rootItemIds():
            tree.expandItemsRecursively(idd)
        treePanel.addComponent(tree)

        # vertically divide the right area
        left = VerticalLayout()
        left.setSizeFull()
        self.addComponent(left)
        main.setExpandRatio(left, 1.0)  # use all available space

        # table on top
        tbl = Table()
        tbl.setWidth('100%')
        tbl.setContainerDataSource(ExampleUtil.getISO3166Container())
        tbl.setSortDisabled(True)
        tbl.setPageLength(7)
        left.addComponent(tbl)

        # Label on bottom
        textPanel = Panel()  # for scrollbars
        textPanel.setStyleName(Reindeer.PANEL_LIGHT)
        textPanel.setSizeFull()
        left.addComponent(textPanel)
        left.setExpandRatio(textPanel, 1.0)  # use all available space

        text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML)
        text.setWidth('500px')  # some limit is good for text
        textPanel.addComponent(text)
Пример #39
0
    def __init__(self):
        super(ApplicationLayoutWindow, self).__init__()

        # Our main layout is a horizontal layout
        main = HorizontalLayout()
        main.setSizeFull()
        self.setContent(main)

        # Tree to the left
        treePanel = Panel()  # for scrollbars
        treePanel.setStyleName(Reindeer.PANEL_LIGHT)
        treePanel.setHeight('100%')
        treePanel.setWidth(None)
        treePanel.getContent().setSizeUndefined()
        self.addComponent(treePanel)

        tree = Tree()
        tree.setContainerDataSource(ExampleUtil.getHardwareContainer())
        tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME)
        for idd in tree.rootItemIds():
            tree.expandItemsRecursively(idd)
        treePanel.addComponent(tree)

        # vertically divide the right area
        left = VerticalLayout()
        left.setSizeFull()
        self.addComponent(left)
        main.setExpandRatio(left, 1.0)  # use all available space

        # table on top
        tbl = Table()
        tbl.setWidth('100%')
        tbl.setContainerDataSource(ExampleUtil.getISO3166Container())
        tbl.setSortDisabled(True)
        tbl.setPageLength(7)
        left.addComponent(tbl)

        # Label on bottom
        textPanel = Panel()  # for scrollbars
        textPanel.setStyleName(Reindeer.PANEL_LIGHT)
        textPanel.setSizeFull()
        left.addComponent(textPanel)
        left.setExpandRatio(textPanel, 1.0)  # use all available space

        text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML)
        text.setWidth('500px')  # some limit is good for text
        textPanel.addComponent(text)
Пример #40
0
    def _create_label(self, item, ui, desc, suffix = ':'):
        """Creates an item label.
        """
        label = item.get_label(ui)
        if (label == '') or (label[-1:] in '?=:;,.<>/\\"\'-+#|'):
            suffix = ''

        control = Label(label + suffix)
        control.setSizeUndefined()

        if item.emphasized:
            self._add_emphasis(control)

        # FIXME: Decide what to do about the help.
        control.help = item.get_help(ui)

        return control
Пример #41
0
 def handleURI(self, context, relativeUri):
     f = FeatureSet.FEATURES.getFeature(relativeUri)
     if f is not None:
         self._window.addComponent(CodeLabel(f.getSource()))
     else:
         lbl = Label('Sorry, no source found for ' + relativeUri)
         self._window.addComponent(lbl)
     return None
Пример #42
0
    def __init__(self):
        super(AccordionIconsExample, self).__init__()

        self.setSpacing(True)

        l1 = Label('There are no previously saved actions.')
        l2 = Label('There are no saved notes.')
        l3 = Label('There are currently no issues.')

        self._a = Accordion()
        self._a.setHeight('300px')
        self._a.setWidth('400px')
        self._a.addTab(l1, 'Saved actions', self._icon1)
        self._a.addTab(l2, 'Notes', self._icon2)
        self._a.addTab(l3, 'Issues', self._icon3)
        self._a.addListener(self, ISelectedTabChangeListener)

        self.addComponent(self._a)
Пример #43
0
    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)
Пример #44
0
    def __init__(self):
        super(LabelRichExample, self).__init__()

        self.setSpacing(True)

        self._editor = RichTextArea()
        self._richText = Label(
            '<h1>Rich text example</h1>'
            '<p>The <b>quick</b> brown fox jumps <sup>over</sup> '
            'the <b>lazy</b> dog.</p>'
            '<p>This text can be edited with the <i>Edit</i> -button</p>')
        self._richText.setContentMode(Label.CONTENT_XHTML)
        self.addComponent(self._richText)

        self._b = Button('Edit')
        self._b.addListener(self, IClickListener)
        self.addComponent(self._b)

        self._editor.setWidth('100%')
Пример #45
0
    def init(self):
        """Init is invoked on application load (when a user accesses
        the application for the first time).
        """
        # Main window is the primary browser window
        main = Window('Hello window')
        self.setMainWindow(main)

        # "Hello world" text is added to window as a Label component
        main.addComponent(Label('Hello World!'))
Пример #46
0
    def __init__(self):
        super(TabSheetDisabledExample, self).__init__()

        self.setSpacing(True)

        # Tab 1 content
        self._l1 = VerticalLayout()
        self._l1.setMargin(True)
        self._l1.addComponent(Label('There are no previously saved actions.'))

        # Tab 2 content
        self._l2 = VerticalLayout()
        self._l2.setMargin(True)
        self._l2.addComponent(Label('There are no saved notes.'))

        # Tab 3 content
        self._l3 = VerticalLayout()
        self._l3.setMargin(True)
        self._l3.addComponent(Label('There are currently no issues.'))

        self._t = TabSheet()
        self._t.setHeight('200px')
        self._t.setWidth('400px')

        self._t1 = self._t.addTab(self._l1, 'Saved actions', self._icon1)
        self._t2 = self._t.addTab(self._l2, 'Notes', self._icon2)
        self._t3 = self._t.addTab(self._l3, 'Issues', self._icon3)

        self._t.addListener(self, tab_sheet.ISelectedTabChangeListener)

        self._toggleEnabled = Button('Disable \'Notes\' tab')
        self._toggleEnabled.addListener(self, button.IClickListener)

        self._toggleVisible = Button('Hide \'Issues\' tab')
        self._toggleVisible.addListener(self, button.IClickListener)

        hl = HorizontalLayout()
        hl.setSpacing(True)
        hl.addComponent(self._toggleEnabled)
        hl.addComponent(self._toggleVisible)

        self.addComponent(self._t)
        self.addComponent(hl)
Пример #47
0
    def __init__(self):
        super(FeatureView, self).__init__()

        self._right = None
        self._left = None
        self._controls = None
        self._title = Label("", Label.CONTENT_XHTML)
        self._showSrc = None
        self._exampleCache = dict()
        self._currentFeature = None
        self._srcWindow = None

        self.setWidth('100%')
        self.setMargin(True)
        self.setSpacing(True)
        self.setStyleName('sample-view')

        self._left = VerticalLayout()
        self._left.setWidth('100%')
        self._left.setSpacing(True)
        self._left.setMargin(False)
        self.addComponent(self._left)
        self.setExpandRatio(self._left, 1)

        rightLayout = VerticalLayout()
        self._right = Panel(rightLayout)
        rightLayout.setMargin(True, False, False, False)
        self._right.setStyleName(Reindeer.PANEL_LIGHT)
        self._right.addStyleName('feature-info')
        self._right.setWidth('319px')
        self.addComponent(self._right)

        self._controls = HorizontalLayout()
        self._controls.setWidth('100%')
        self._controls.setStyleName('feature-controls')

        self._title.setStyleName('title')
        self._controls.addComponent(self._title)
        self._controls.setExpandRatio(self._title, 1)

        resetExample = NativeButton('Reset', ResetListener(self))
        resetExample.setStyleName(BaseTheme.BUTTON_LINK)
        resetExample.addStyleName('reset')
        resetExample.setDescription('Reset Sample')
        self._controls.addComponent(resetExample)
        self._showSrc = ActiveLink()
        self._showSrc.setDescription('Right / middle / ctrl / shift -click for browser window/tab')

        self._showSrc.addListener(ShowSrcListener(self), ILinkActivatedListener)
        self._showSrc.setCaption(self._MSG_SHOW_SRC)
        self._showSrc.addStyleName('showcode')
        self._showSrc.setTargetBorder(Link.TARGET_BORDER_NONE)
        self._controls.addComponent(self._showSrc)
Пример #48
0
 def setPath(self, path):
     # could be optimized: always builds path from scratch home
     self._layout.removeAllComponents()
     link = ActiveLink('Home', ExternalResource('#'))
     link.addListener(self, ILinkActivatedListener)
     self._layout.addComponent(link)
     if path is not None and not ('' == path):
         parts = path.split('/')
         link = None
         for part in parts:
             separator = Label("&raquo;", Label.CONTENT_XHTML);
             separator.setSizeUndefined()
             self._layout.addComponent(separator)
             f = FeatureSet.FEATURES.getFeature(part)
             link = ActiveLink(f.getName(),
                     ExternalResource('#' + f.getFragmentName()))
             link.setData(f)
             link.addListener(self, ILinkActivatedListener)
             self._layout.addComponent(link)
         if link is not None:
             link.setStyleName('bold')
Пример #49
0
    def __init__(self):
        super(PopupViewClosingExample, self).__init__()

        self.setSpacing(True)

        # Create the content for the popup
        content = Label('This popup will close as soon as you move the '
                'mouse cursor outside of the popup area.')
        # The PopupView popup will be as large as needed by the content
        content.setWidth('300px')
        # Construct the PopupView with simple HTML text representing the
        # minimized view
        popup = PopupView('Default popup', content)
        popup.setHideOnMouseOut(True)
        popup.addListener(self, IPopupVisibilityListener)
        self.addComponent(popup)

        content = Label('This popup will only close if you click '
                'the mouse outside the popup area.')
        # The PopupView popup will be as large as needed by the content
        content.setWidth('300px')
        popup = PopupView('Popup that won\'t auto-close', content)
        popup.setHideOnMouseOut(False)
        popup.addListener(self, IPopupVisibilityListener)
        self.addComponent(popup)
Пример #50
0
class ReadonlyEditor ( Editor ):
    """ Base class for read-only style editors, which displays a read-only 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 = Label()
        self.control.setImmediate(True)
        self.control.setValue( str(self.str_value) )

#        if self.item.resizable is True or self.item.height != -1.0:
#            self.control.setSizePolicy(QtGui.QSizePolicy.Expanding,
#                                       QtGui.QSizePolicy.Expanding)
#            self.control.setWordWrap(True)

        self.set_tooltip()

    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------

    def update_editor ( self ):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        self.control.setValue( str(self.str_value) )
Пример #51
0
class MuntjacLabel(MuntjacControl, AbstractTkLabel):
    """ A Muntjac implementation of Label.

    """
    #--------------------------------------------------------------------------
    # Setup methods
    #--------------------------------------------------------------------------
    def create(self, parent):
        """ Creates the underlying Label control.

        """
        self.widget = Label()
        parent.addComponent(self.widget)

    def initialize(self):
        """ Initializes the attributes on the underlying control.

        """
        super(MuntjacLabel, self).initialize()
        self.set_label(self.shell_obj.text)

    #--------------------------------------------------------------------------
    # Implementation
    #--------------------------------------------------------------------------
    def shell_text_changed(self, text):
        """ The change handler for the 'text' attribute.

        """
        self.set_label(text)
        # If the text in the label changes, then the size hint of
        # label will have changed, and the layout system needs to
        # be informed.
        self.shell_obj.size_hint_updated = True

    def set_label(self, label):
        """ Sets the label on the underlying control.

        """
        self.widget.setValue(label)
Пример #52
0
    def __init__(self):
        super(SliderVerticalExample, self).__init__()

        self.setSpacing(True)

        value = Label('0')
        value.setSizeUndefined()

        slider = Slider('Select a value between 0 and 100')
        slider.setOrientation(Slider.ORIENTATION_VERTICAL)
        slider.setHeight('200px')
        slider.setMin(0)
        slider.setMax(100)
        slider.setImmediate(True)

        slider.addListener(SliderListener(value), IValueChangeListener)

        self.addComponent(slider)
        self.addComponent(value)

        self.setComponentAlignment(slider, Alignment.TOP_CENTER)
        self.setComponentAlignment(value, Alignment.TOP_CENTER)
Пример #53
0
    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = Label()
        self.control.setImmediate(True)
        self.control.setValue( str(self.str_value) )

#        if self.item.resizable is True or self.item.height != -1.0:
#            self.control.setSizePolicy(QtGui.QSizePolicy.Expanding,
#                                       QtGui.QSizePolicy.Expanding)
#            self.control.setWordWrap(True)

        self.set_tooltip()
Пример #54
0
    def __init__(self):
        super(SliderHorizontalExample, self).__init__()

        self.setSpacing(True)

        self.setWidth('100%')

        value = Label('0')
        value.setWidth('3em')

        slider = Slider('Select a value between 0 and 100')
        slider.setWidth('100%')
        slider.setMin(0)
        slider.setMax(100)
        slider.setImmediate(True)

        slider.addListener(SliderListener(value), IValueChangeListener)

        self.addComponent(slider)
        self.setExpandRatio(slider, 1)
        self.addComponent(value)

        self.setComponentAlignment(value, Alignment.BOTTOM_LEFT)
Пример #55
0
    def __init__ ( self, parent, html, scale_dx, scale_dy ):
        """ Initializes the object.
        """
        super(HTMLHelpWindow, self).__init__()
        self.setParent(parent)

        layout = VerticalLayout()
        layout.setMargin(False)

        # Create the html control
        html_control = Label(html)
        html_control.setContentMode(Label.CONTENT_XHTML)
        layout.addComponent(html_control)

        # Create the OK button
        ok = Button('OK')
        # FIXME: add event handler
        layout.addComponent(ok)
        layout.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT)

        # Position and show the dialog
        position_window(self, parent=parent)
        self.show()
Пример #56
0
class MuntjacHtml(MuntjacControl, AbstractTkHtml):
    """ A Muntjac implementation of Html.

    """
    #--------------------------------------------------------------------------
    # Setup methods
    #--------------------------------------------------------------------------
    def create(self, parent):
        """ Creates the underlying widget to display HTML.

        """
        self.widget = Label()
        self.widget.setContentMode(Label.CONTENT_XHTML)
        parent.addComponent(self.widget)

    def initialize(self):
        """ Initializes the attributes of the control.

        """
        super(MuntjacHtml, self).initialize()
        self.set_page_source(self.shell_obj.source)

    #--------------------------------------------------------------------------
    # Implementation
    #--------------------------------------------------------------------------
    def shell_source_changed(self, source):
        """ The change handler for the 'source' attribute.

        """
        self.set_page_source(source)

    def set_page_source(self, source):
        """ Sets the page source for the underlying control.

        """
        self.widget.setValue(source)
Пример #57
0
    def __init__(self):
        super(CssLayoutsExample, self).__init__()

        self.setMargin(True)

        # Note, that this code example may not be self explanatory without
        # checking out the related CSS file in the sampler theme.

        panel = Panel('Panel')
        panel.setStyleName('floatedpanel')
        panel.setWidth('30%')
        panel.setHeight('370px')
        panel.addComponent(Label('This panel is 30% wide '
                + 'and 370px high (defined on the server side) '
                + 'and floated right (with custom css). '
                + 'Try resizing the browser window to see '
                + 'how the black boxes (floated left) '
                + 'behave. Every third of them has colored text '
                + 'to demonstrate the dynamic css injection.'))

        bottomCenter = Label(
                'I\'m a 3 inches wide footer at the bottom of the layout')
        bottomCenter.setSizeUndefined()  # disable 100% default width
        bottomCenter.setStyleName('footer')

        cssLayout = MyCssLayout()
        cssLayout.setWidth('100%')

        cssLayout.addComponent(panel)
        for _ in range(15):
            # add black labels that float left
            cssLayout.addComponent(Brick())

        cssLayout.addComponent(bottomCenter)

        self.addComponent(cssLayout)