当前位置: 首页>>代码示例>>Python>>正文


Python FlexTable.setCellSpacing方法代码示例

本文整理汇总了Python中pyjamas.ui.FlexTable.FlexTable.setCellSpacing方法的典型用法代码示例。如果您正苦于以下问题:Python FlexTable.setCellSpacing方法的具体用法?Python FlexTable.setCellSpacing怎么用?Python FlexTable.setCellSpacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.ui.FlexTable.FlexTable的用法示例。


在下文中一共展示了FlexTable.setCellSpacing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MailList

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setCellSpacing [as 别名]
class MailList(Composite):

    VISIBLE_EMAIL_COUNT = 10

    def __init__(self, mailObject):
        Composite.__init__(self)

        self.countLabel = HTML()
        self.newerButton = HTML("<a href='javascript:;'>&lt; newer</a>", True)
        self.olderButton = HTML("<a href='javascript:;'>older &gt;</a>", True)
        self.startIndex = 0
        self.selectedRow = -1
        self.table = FlexTable()
        self.navBar = HorizontalPanel()
        self.mailObject = mailObject

        # Setup the table.
        self.table.setCellSpacing(0)
        self.table.setCellPadding(2)
        self.table.setWidth("100%")

        # Hook up events.
        self.table.addTableListener(self)
        self.newerButton.addClickListener(self)
        self.olderButton.addClickListener(self)

        # Create the 'navigation' bar at the upper-right.
        innerNavBar = HorizontalPanel()
        innerNavBar.setSpacing(8)
        innerNavBar.add(self.newerButton)
        innerNavBar.add(self.countLabel)
        innerNavBar.add(self.olderButton)

        self.navBar.setStyleName("mail-ListNavBar")
        self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
        self.navBar.add(innerNavBar)
        self.navBar.setWidth("100%")

        self.initWidget(self.table)
        self.setStyleName("mail-List")

        self.initTable()
        self.update()

    def onCellDoubleClicked(self, sender, row, cell):
    	pass

    def onCellClicked(self, sender, row, cell):
        # Select the row that was clicked (-1 to account for header row).
        if (row > 0):
            self.selectRow(row - 1)

    def onClick(self, sender):
        if (sender == self.olderButton):
            # Move forward a page.
            self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
            if (self.startIndex >= MailItems().getMailItemCount()):
                self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
            else:
                self.styleRow(self.selectedRow, False)
                self.selectedRow = -1
                self.update()

        elif (sender == self.newerButton):
            # Move back a page.
            self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
            if (self.startIndex < 0):
                self.startIndex = 0
            else:
                self.styleRow(self.selectedRow, False)
                self.selectedRow = -1
                self.update()

    def initTable(self):
        # Create the header row.
        self.table.setText(0, 0, "sender")
        self.table.setText(0, 1, "email")
        self.table.setText(0, 2, "subject")
        self.table.setWidget(0, 3, self.navBar)
        self.table.getRowFormatter().setStyleName(0, "mail-ListHeader")

        # Initialize the rest of the rows.
        i = 0
        while i < MailList.VISIBLE_EMAIL_COUNT:
            self.table.setText(i + 1, 0, "")
            self.table.setText(i + 1, 1, "")
            self.table.setText(i + 1, 2, "")
            self.table.getCellFormatter().setWordWrap(i + 1, 0, False)
            self.table.getCellFormatter().setWordWrap(i + 1, 1, False)
            self.table.getCellFormatter().setWordWrap(i + 1, 2, False)
            self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2)
            i = i + 1


    def selectRow(self, row):
        # When a row (other than the first one, which is used as a header) is
        # selected, display its associated MailItem.
        item = MailItems().getMailItem(self.startIndex + row)
        if item is None:
            return
#.........这里部分代码省略.........
开发者ID:Ludovic-Condette,项目名称:pyjs,代码行数:103,代码来源:MailList.py

示例2: CollapserPanel

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setCellSpacing [as 别名]
class CollapserPanel(SimplePanel):
    def __init__(self, sink):
        SimplePanel.__init__(self)
        self.sink = sink
        self.caption = HTML()
        self.child = None 
        self.showing = False
        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.panel = FlexTable()

        self.collapse = Image("./images/cancel.png")
        self.collapse.addClickListener(self)
        dock = DockPanel()
        dock.setSpacing(0)
        
        dock.add(self.collapse, DockPanel.EAST)
        dock.add(self.caption, DockPanel.WEST)

        dock.setCellHorizontalAlignment(self.collapse, HasAlignment.ALIGN_RIGHT)
        dock.setCellVerticalAlignment(self.collapse, HasAlignment.ALIGN_TOP)
        dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
        dock.setCellWidth(self.caption, "100%")
        dock.setWidth("100%")
        dock.setHeight("100%")

        self.panel.setWidget(0, 0, dock)
        self.panel.setHeight("100%")
        self.panel.setWidth("100%")
        self.panel.setBorderWidth(0)
        self.panel.setCellPadding(0)
        self.panel.setCellSpacing(0)
        self.panel.getCellFormatter().setHeight(1, 0, "100%")
        self.panel.getCellFormatter().setWidth(1, 0, "100%")
        self.panel.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP)
        SimplePanel.setWidget(self, self.panel)

        self.setStyleName("gwt-DialogBox")
        self.caption.setStyleName("Caption")
        self.collapse.setStyleName("Close")
        dock.setStyleName("Header")
        #self.caption.addMouseListener(self)
        self.collapsed = False

        self.collapsed_width = "15px"
        self.uncollapsed_width = "100%"

    def setInitialWidth(self, width):
        self.uncollapsed_width = width
        SimplePanel.setWidth(self, width)
        self.sink.setCollapserWidth(self, width)

    def setHeight(self, height):
        SimplePanel.setHeight(self, height)

    def onClick(self, sender):
        if self.collapsed == False:
            self.collapse.setUrl("./tree_closed.gif")
            self.collapsed = True
            self.caption.setVisible(False)
            if self.child:
                self.child.setVisible(False)
            self.setWidth(self.collapsed_width)
            self.sink.setCollapserWidth(self, self.collapsed_width)
        else:
            self.collapse.setUrl("./images/cancel.png")
            self.collapsed = False
            self.caption.setVisible(True)
            if self.child:
                self.child.setVisible(True)
            self.setWidth(self.uncollapsed_width)
            self.sink.setCollapserWidth(self, self.uncollapsed_width)

    def setHTML(self, html):
        self.caption.setHTML(html)

    def setText(self, text):
        self.caption.setText(text)

    def remove(self, widget):
        if self.child != widget:
            return False

        self.panel.remove(widget)
        return True

    def doAttachChildren(self):
        SimplePanel.doAttachChildren(self)
        self.caption.onAttach()

    def doDetachChildren(self):
        SimplePanel.doDetachChildren(self)
        self.caption.onDetach()

    def setWidget(self, widget):
        if self.child is not None:
            self.panel.remove(self.child)

        if widget is not None:
#.........这里部分代码省略.........
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:103,代码来源:InfoDirectory.py

示例3: DialogBoxModal

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setCellSpacing [as 别名]
class DialogBoxModal(PopupPanel):
    def __init__(self, identifier, autoHide=None, modal=False, rootpanel=None):
        PopupPanel.__init__(self, autoHide, modal, rootpanel)

        self.identifier = identifier
        self.caption = HTML()
        self.child = None
        self.showing = False
        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.panel = FlexTable()

        self.closeButton = Image('cancel.png')
        self.closeButton.addClickListener(self)
        dock = DockPanel()
        dock.setSpacing(0)

        dock.add(self.closeButton, DockPanel.EAST)
        dock.add(self.caption, DockPanel.WEST)

        dock.setCellHorizontalAlignment(self.closeButton,
                                        HasAlignment.ALIGN_RIGHT)
        dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
        dock.setCellWidth(self.caption, '100%')
        dock.setWidth('100%')

        self.panel.setWidget(0, 0, dock)
        self.panel.setHeight('100%')
        self.panel.setBorderWidth(0)
        self.panel.setCellPadding(0)
        self.panel.setCellSpacing(0)
        self.panel.getCellFormatter().setHeight(1, 0, '100%')
        self.panel.getCellFormatter().setWidth(1, 0, '100%')
        #self.panel.getCellFormatter().setAlignment(1, 0,
        # HasHorizontalAlignment.ALIGN_CENTER,
        # HasVerticalAlignment.ALIGN_MIDDLE)
        PopupPanel.setWidget(self, self.panel)

        self.setStyleName('gwt-DialogBox')
        self.caption.setStyleName('Caption')
        self.closeButton.setStyleName('Close')
        dock.setStyleName('Header')
        self.caption.addMouseListener(self)

    def getHTML(self):
        return self.caption.getHTML()

    def getText(self):
        return self.caption.getText()

    def onMouseDown(self, sender, x, y):
        self.dragging = True
        DOM.setCapture(self.caption.getElement())
        self.dragStartX = x
        self.dragStartY = y

    def onMouseEnter(self, sender):
        pass

    def onMouseLeave(self, sender):
        pass

    def onMouseMove(self, sender, x, y):
        if self.dragging:
            absX = x + self.getAbsoluteLeft()
            absY = y + self.getAbsoluteTop()
            self.setPopupPosition(absX - self.dragStartX,
                                  absY - self.dragStartY)

    def onMouseUp(self, sender, x, y):
        self.dragging = False
        DOM.releaseCapture(self.caption.getElement())

    def remove(self, widget):
        if self.child != widget:
            return False

        self.panel.remove(widget)
        self.child = None
        return True

    def setHTML(self, html):
        self.caption.setHTML(html)

    def setText(self, text):
        self.caption.setText(text)

    def doAttachChildren(self):
        PopupPanel.doAttachChildren(self)
        self.caption.onAttach()

    def doDetachChildren(self):
        PopupPanel.doDetachChildren(self)
        self.caption.onDetach()

    def setWidget(self, widget):
        if self.child is not None:
            self.panel.remove(self.child)

#.........这里部分代码省略.........
开发者ID:fluidinfo,项目名称:Tickery,代码行数:103,代码来源:Popups.py

示例4: RightGrid

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import setCellSpacing [as 别名]
class RightGrid(DockPanel):

    def __init__(self, title):
        DockPanel.__init__(self)
        self.grid = FlexTable()
        title = HTML(title)
        self.add(title, DockPanel.NORTH)
        self.setCellHorizontalAlignment(title,
                                        HasHorizontalAlignment.ALIGN_LEFT)
        self.add(self.grid, DockPanel.CENTER)
        self.grid.setBorderWidth("0px")
        self.grid.setCellSpacing("0px")
        self.grid.setCellPadding("4px")

        self.formatCell(0, 0)
        self.grid.setHTML(0, 0, "&nbsp;")

    def clear_items(self):
        self.index = 0
        self.items = {}

    def set_items(self, items):
        self.items = items
        self.index = 0
        self.max_rows = 0
        self.max_cols = 0
        Timer(1, self)

    def onTimer(self, t):
        count = 0
        while count < 10 and self.index < len(self.items):
            self._add_items(self.index)
            self.index += 1
            count += 1
        if self.index < len(self.items):
            Timer(1, self)

    def _add_items(self, i):

        item = self.items[i]
        command = item[0]
        col = item[1]
        row = item[2]
        data = item[3]

        format_row = -1
        format_col = -1
        if col+1 > self.max_cols:
            format_col = self.max_cols
            #self.grid.resizeColumns(col+1)
            self.max_cols = col+1

        if row+1 >= self.max_rows:
            format_row = self.max_rows
            #self.grid.resizeRows(row+1)
            self.max_rows = row+1

        if format_row >= 0:
            for k in range(format_row, self.max_rows):
                self.formatCell(k, 0)

        self.formatCell(row, col)

        cf = self.grid.getCellFormatter()

        if command == 'data':
            self.grid.setHTML(row, col, data)
        elif command == 'cellstyle':
            data = space_split(data)
            attr = data[0]
            val = data[1]
            cf.setStyleAttr(row, col, attr, val)
        elif command == 'align':
            data = space_split(data)
            vert = data[0]
            horiz = data[1]
            if vert != '-':
                cf.setVerticalAlignment(row, col, vert)
            if horiz != '-':
                cf.setHorizontalAlignment(row, col, horiz)
        elif command == 'cellspan':
            data = space_split(data)
            rowspan = data[0]
            colspan = data[1]
            if colspan != '-':
                cf.setColSpan(row, col, colspan)
            if rowspan != '-':
                cf.setRowSpan(row, col, rowspan)

    def formatCell(self, row, col):
        self.grid.prepareCell(row, col)
        if col == 0 and row != 0:
            self.grid.setHTML(row, col, "%d" % row)
        if row != 0 and col != 0:
            #self.grid.setHTML(row, col, "&nbsp;")
            fmt = "rightpanel-cellformat"
        if col == 0 and row == 0:
            fmt = "rightpanel-cellcornerformat"
        elif row == 0:
            fmt = "rightpanel-celltitleformat"
#.........这里部分代码省略.........
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:103,代码来源:InfoDirectory.py


注:本文中的pyjamas.ui.FlexTable.FlexTable.setCellSpacing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。