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
示例#2
0
    def init(self):
        # Application.init is called once for each application. Here it
        # creates the UI and connects it to the business logic.

        # Create the main layout for our application (4 columns, 5 rows)
        layout = GridLayout(4, 5)

        # Create the main window for the application using the main layout.
        # The main window is shown when the application is starts.
        self.setMainWindow(Window('Calculator Application', layout))

        # Create a result label that over all 4 columns in the first row
        layout.addComponent(self._display, 0, 0, 3, 0)

        # The operations for the calculator in the order they appear on the
        # screen (left to right, top to bottom)
        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)
示例#3
0
    def __init__(self, personItem, c):
        self._c = c

        super(FormWithComplexLayout, self).__init__()

        # Override to get control over where fields are placed.
        self.setCaption('Personal details')

        # Create our layout (3x3 GridLayout)
        self._ourLayout = GridLayout(3, 3)

        # Use top-left margin and spacing
        self._ourLayout.setMargin(True, False, False, True)
        self._ourLayout.setSpacing(True)

        self.setLayout(self._ourLayout)

        # Set up buffering
        self.setWriteThrough(False)  # we want explicit 'apply'
        self.setInvalidCommitted(False)  # no invalid values in datamodel

        # FieldFactory for customizing the fields and adding validators
        self.setFormFieldFactory(PersonFieldFactory(self))
        self.setItemDataSource(personItem)  # bind to POJO via BeanItem

        # Determines which properties are shown, and in which order:
        self.setVisibleItemProperties([
            'firstName', 'lastName', 'countryCode', 'password', 'birthdate',
            'shoesize'
        ])
示例#4
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
示例#5
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)
    def __init__(self):
        super(GridLayoutBasicExample, self).__init__()

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

        # The style allows us to visualize the cell borders in this example.
        grid.addStyleName('gridexample')

        grid.setWidth(400, ISizeable.UNITS_PIXELS)
        grid.setHeight(400, ISizeable.UNITS_PIXELS)

        # First we insert four components that occupy one cell each
        topleft = Button('Top Left')
        grid.addComponent(topleft, 0, 0)
        grid.setComponentAlignment(topleft, Alignment.MIDDLE_CENTER)

        topcenter = Button('Top Center')
        grid.addComponent(topcenter, 1, 0)
        grid.setComponentAlignment(topcenter, Alignment.MIDDLE_CENTER)

        bottomleft = Button('Bottom Left')
        grid.addComponent(bottomleft, 0, 2)
        grid.setComponentAlignment(bottomleft, Alignment.MIDDLE_CENTER)

        bottomcenter = Button('Bottom Center')
        grid.addComponent(bottomcenter, 1, 2)
        grid.setComponentAlignment(bottomcenter, Alignment.MIDDLE_CENTER)

        # Insert a component that occupies all the rightmost cells
        topright = Button('Extra height')
        grid.addComponent(topright, 2, 0, 2, 2)
        grid.setComponentAlignment(topright, Alignment.MIDDLE_CENTER)

        # Insert a component that occupies two cells in horizontal direction
        middleleft = Button('This is a wide cell in GridLayout')
        grid.addComponent(middleleft, 0, 1, 1, 1)
        grid.setComponentAlignment(middleleft, Alignment.MIDDLE_CENTER)

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

        # Align the grid itself within its container layout.
        self.setComponentAlignment(grid, Alignment.MIDDLE_CENTER)
示例#7
0
    def addTestButtons(self):
        grid = GridLayout(4, 1)
        grid.setSpacing(True)
        self.getMainWindow().addComponent(grid)

        l = DraggabilityClickListener(self)
        grid.addComponent(Button('Toggle marker 3 draggability', l))

        l = VisibilityClickListener(self)
        grid.addComponent(Button('Toggle marker 4 visibility', l))

        l = RandomizeClickListener(self)
        grid.addComponent(Button('Randomize Marker 5 location', l))

        l = UpdateClickListener(self)
        grid.addComponent(Button('Update marker 5 title', l))

        l = RemoveClickListener(self)
        grid.addComponent(Button('Remove \"Test marker2\"', l))

        l = AddClickListener(self)
        grid.addComponent(Button('Add \"Test marker2\"', l))

        l = ToggleMarkerClickListener(self)
        grid.addComponent(Button('Toggle marker 1 icon', l))

        l = ToggleLoggingClickListener(self)
        grid.addComponent(Button('Toggle client logging', l))

        # Popup test
        l = PopupClickListener(self)
        grid.addComponent(Button('Open a map in a popup', l))

        l = ResizeClickListener(self)
        grid.addComponent(Button('Resize map', l))

        l = DrawClickListener(self)
        grid.addComponent(Button('Draw polygon', l))

        l = RemovePolygonClickListener(self)
        grid.addComponent(Button('Remove first polygon', l))
    def createChildComponentClickableLayout(self):
        # Create a grid layout with click events
        layout = GridLayout(5, 2)
        layout.addStyleName('border')
        layout.setSpacing(True)
        layout.setWidth('90%')
        layout.setMargin(True)

        # Add some components to the layout
        layout.addComponent(
            Label(
                '<b>Clickable layout events include a '
                'reference to the child component beneath the click. '
                'Try clicking anywhere in this layout.</b>',
                Label.CONTENT_RAW), 0, 0, 4, 0)
        layout.addComponent(TextField(None, 'Click here'))
        layout.addComponent(Link('Click here', None))
        select = Select(None, ['Click here'])
        select.select('Click here')
        layout.addComponent(select)

        # Listen for layout click event
        layout.addListener(GridListener(self), ILayoutClickListener)
        return layout
    def init(self):
        mainWindow = Window('CodeMirror Sample Application')

        hl = GridLayout(2, 5)
        hl.setSpacing(True)
        mainWindow.addComponent(hl)

        # #1
        code = CodeMirror('Your Code', CodeMode.TEXT)
        code.setValue(self._SAMPLE_CODE)
        code.setWidth('500px')
        code.setHeight('350px')
        hl.addComponent(code)

        # #2
        code2 = CodeMirror('Your Code Too', CodeMode.PYTHON)
        code2.setValue(self._SAMPLE_CODE)
        #        code2.setWidth('400px')
        #        code2.setHeight('300px')
        hl.addComponent(code2)

        codeMode = Select('Select your mode')
        for cs in CodeMode.values():
            codeMode.addItem(cs)
        codeMode.setNewItemsAllowed(False)
        codeMode.setNullSelectionAllowed(False)
        codeMode.setImmediate(True)
        hl.addComponent(codeMode)

        l = CodeModeChangeListener(code, codeMode)
        codeMode.addListener(l, IValueChangeListener)
        codeMode.setValue(CodeMode.TEXT)

        codeMode = Select('Select your mode too')
        for cs in CodeMode.values():
            codeMode.addItem(cs)
        codeMode.setNewItemsAllowed(False)
        codeMode.setNullSelectionAllowed(False)
        codeMode.setImmediate(True)
        hl.addComponent(codeMode)

        l = CodeModeChangeListener(code2, codeMode)
        codeMode.addListener(l, IValueChangeListener)
        codeMode.setValue(CodeMode.PYTHON)

        codeTheme = Select('Select your theme')
        for ct in CodeTheme.values():
            codeTheme.addItem(ct)
        codeTheme.setNewItemsAllowed(False)
        codeTheme.setImmediate(True)
        hl.addComponent(codeTheme)

        l = CodeThemeChangeListener(code, codeTheme)
        codeTheme.addListener(l, IValueChangeListener)
        codeTheme.setValue(CodeTheme.DEFAULT)

        codeTheme = Select('Select your theme too')
        for ct in CodeTheme.values():
            codeTheme.addItem(ct)
        codeTheme.setNewItemsAllowed(False)
        codeTheme.setImmediate(True)
        hl.addComponent(codeTheme)

        l = CodeThemeChangeListener(code2, codeTheme)
        codeTheme.addListener(l, IValueChangeListener)
        codeTheme.setValue(CodeTheme.ECLIPSE)

        l = CopyClickListener(code, code2)
        hl.addComponent(Button('copy to -->', l))

        l = CopyClickListener(code2, code)
        hl.addComponent(Button('<- copy to', l))

        l = ShowLineNumbersListener(code)
        cb = CheckBox("Show line numbers", l)
        cb.setImmediate(True)
        hl.addComponent(cb)

        l = ShowLineNumbersListener(code2)
        cb = CheckBox("Show line numbers", l)
        cb.setImmediate(True)
        hl.addComponent(cb)

        self.setMainWindow(mainWindow)