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


Python FlexTable.prepareCell方法代码示例

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


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

示例1: RightGrid

# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import prepareCell [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, " ")

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