Пример #1
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)
Пример #2
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)
Пример #3
0
class TableStylingExample(VerticalLayout):

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

        self.setSpacing(True)

        self._table = Table()
        self._markedRows = dict()
        self._markedCells = dict()

        self.addComponent(self._table)

        # set a style name, so we can style rows and cells
        self._table.setStyleName('contacts')

        # size
        self._table.setWidth('100%')
        self._table.setPageLength(7)

        # connect data source
        self._table.setContainerDataSource(ExampleUtil.getPersonContainer())

        # Generate the email-link from firstname & lastname
        self._table.addGeneratedColumn('Email', TableColumnGenerator(self))

        # turn on column reordering and collapsing
        self._table.setColumnReorderingAllowed(True)
        self._table.setColumnCollapsingAllowed(True)

        # Actions (a.k.a context menu)
        self._table.addActionHandler( TableActionHandler(self) )

        # style generator
        self._table.setCellStyleGenerator( TableStyleGenerator(self) )

        # toggle cell 'marked' styling when double-clicked
        self._table.addListener(TableClickListener(self), IItemClickListener)

        # Editing

        # we don't want to update container before pressing 'save':
        self._table.setWriteThrough(False)

        # edit button
        editButton = Button('Edit')
        self.addComponent(editButton)

        editButton.addListener(EditListener(self, editButton),
                button.IClickListener)

        self.setComponentAlignment(editButton, Alignment.TOP_RIGHT)
Пример #4
0
class TableStylingExample(VerticalLayout):

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

        self.setSpacing(True)

        self._table = Table()
        self._markedRows = dict()
        self._markedCells = dict()

        self.addComponent(self._table)

        # set a style name, so we can style rows and cells
        self._table.setStyleName('contacts')

        # size
        self._table.setWidth('100%')
        self._table.setPageLength(7)

        # connect data source
        self._table.setContainerDataSource(ExampleUtil.getPersonContainer())

        # Generate the email-link from firstname & lastname
        self._table.addGeneratedColumn('Email', TableColumnGenerator(self))

        # turn on column reordering and collapsing
        self._table.setColumnReorderingAllowed(True)
        self._table.setColumnCollapsingAllowed(True)

        # Actions (a.k.a context menu)
        self._table.addActionHandler( TableActionHandler(self) )

        # style generator
        self._table.setCellStyleGenerator( TableStyleGenerator(self) )

        # toggle cell 'marked' styling when double-clicked
        self._table.addListener(TableClickListener(self), IItemClickListener)

        # Editing

        # we don't want to update container before pressing 'save':
        self._table.setWriteThrough(False)

        # edit button
        editButton = Button('Edit')
        self.addComponent(editButton)

        editButton.addListener(EditListener(self, editButton),
                button.IClickListener)

        self.setComponentAlignment(editButton, Alignment.TOP_RIGHT)
Пример #5
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)
    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)
Пример #7
0
    def __init__(self):
        super(TableFooterExample, self).__init__()

        # Create our data source
        dataSource = ExampleUtil.getOrderContainer()

        # Calculate total sum
        totalSum = 0.0
        for i in range(len(dataSource)):
            item = dataSource.getItem(dataSource.getIdByIndex(i))
            value = item.getItemProperty(
                ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue()

            match = re.search(self.CURRENCY_PATTERN, str(value))
            if match is not None:
                amount = match.groups()[1]
                totalSum += float(amount)

        # Create a table to show the data in
        table = Table('Order table', dataSource)
        table.setPageLength(6)
        table.setWidth('100%')

        # Set alignments
        table.setColumnAlignments([
            Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT,
            Table.ALIGN_RIGHT
        ])

        # Set column widths
        table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID,
                                   1)

        # Enable footer
        table.setFooterVisible(True)

        # Add some total sum and description to footer
        table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID,
                              'Total Price')
        l = defaultLocale()
        fc = format_currency(totalSum, currency='USD',
                             locale=l).encode('utf-8')
        table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc)

        self.addComponent(table)
Пример #8
0
    def __init__(self):
        super(TableClickListenersExample, self).__init__()

        # Create our data source
        dataSource = ExampleUtil.getOrderContainer()

        # Calculate total sum
        totalSum = 0.0
        for i in range(len(dataSource)):
            item = dataSource.getItem(dataSource.getIdByIndex(i))
            value = item.getItemProperty(
                    ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue()

            #amount = NumberFormat.getCurrencyInstance().parse(str(value))
            amount = re.search(u'([\u00A3\u0024\u20AC])(\d+(?:\.\d{2})?)',
                    str(value)).groups()[1]

            totalSum += float(amount)

        # Create table
        table = Table('', ExampleUtil.getOrderContainer())
        table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1)
        table.setSortDisabled(True)
        table.setWidth('100%')
        table.setPageLength(6)
        table.setFooterVisible(True)
        table.setImmediate(True)

        # Add some total sum and description to footer
        table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID,
                'Total Price')
        l = defaultLocale()
        fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8')
        table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc)

        # Add a header click handler
        table.addListener(HeaderListener(self), IHeaderClickListener)

        # Add a footer click handler
        table.addListener(FooterListener(self), IFooterClickListener)
        self.addComponent(table)
Пример #9
0
    def __init__(self):
        super(TableFooterExample, self).__init__()

        # Create our data source
        dataSource = ExampleUtil.getOrderContainer()

        # Calculate total sum
        totalSum = 0.0
        for i in range(len(dataSource)):
            item = dataSource.getItem(dataSource.getIdByIndex(i))
            value = item.getItemProperty(
                    ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue()

            match = re.search(self.CURRENCY_PATTERN, str(value))
            if match is not None:
                amount = match.groups()[1]
                totalSum += float(amount)

        # Create a table to show the data in
        table = Table('Order table', dataSource)
        table.setPageLength(6)
        table.setWidth('100%')

        # Set alignments
        table.setColumnAlignments([Table.ALIGN_LEFT, Table.ALIGN_RIGHT,
                Table.ALIGN_RIGHT, Table.ALIGN_RIGHT])

        # Set column widths
        table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1)

        # Enable footer
        table.setFooterVisible(True)

        # Add some total sum and description to footer
        table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID,
                'Total Price')
        l = defaultLocale()
        fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8')
        table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc)

        self.addComponent(table)
    def __init__(self):
        super(TableClickListenersExample, self).__init__()

        # Create our data source
        dataSource = ExampleUtil.getOrderContainer()

        # Calculate total sum
        totalSum = 0.0
        for i in range(len(dataSource)):
            item = dataSource.getItem(dataSource.getIdByIndex(i))
            value = item.getItemProperty(
                    ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue()

            match = re.search(self.CURRENCY_PATTERN, str(value))
            if match is not None:
                amount = match.groups()[1]
                totalSum += float(amount)

        # Create table
        table = Table('', ExampleUtil.getOrderContainer())
        table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1)
        table.setSortDisabled(True)
        table.setWidth('100%')
        table.setPageLength(6)
        table.setFooterVisible(True)
        table.setImmediate(True)

        # Add some total sum and description to footer
        table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID,
                'Total Price')
        l = defaultLocale()
        fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8')
        table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc)

        # Add a header click handler
        table.addListener(HeaderListener(self), IHeaderClickListener)

        # Add a footer click handler
        table.addListener(FooterListener(self), IFooterClickListener)
        self.addComponent(table)
Пример #11
0
    def __init__(self):
        super(TableFooterExample, self).__init__()

        # Create our data source
        dataSource = ExampleUtil.getOrderContainer()

        # Calculate total sum
        totalSum = 0.0
        for i in range(len(dataSource)):
            item = dataSource.getItem(dataSource.getIdByIndex(i))
            value = item.getItemProperty(
                    ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue()

            amount = re.search(u'([\u00A3\u0024\u20AC])(\d+(?:\.\d{2})?)',
                    str(value)).groups()[1]
            totalSum += float(amount)

        # Create a table to show the data in
        table = Table('Order table', dataSource)
        table.setPageLength(6)
        table.setWidth('100%')

        # Set alignments
        table.setColumnAlignments([Table.ALIGN_LEFT, Table.ALIGN_RIGHT,
                Table.ALIGN_RIGHT, Table.ALIGN_RIGHT])

        # Set column widths
        table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1)

        # Enable footer
        table.setFooterVisible(True)

        # Add some total sum and description to footer
        table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID,
                'Total Price')
        table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID,
                locale.currency(totalSum, grouping=True))  # FIXME: babel

        self.addComponent(table)