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


Python Grid.setWidth方法代码示例

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


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

示例1: drawGrid

# 需要导入模块: from Grid import Grid [as 别名]
# 或者: from Grid.Grid import setWidth [as 别名]
    def drawGrid(self,month,year):
        # draw the grid in the middle of the calendar

        daysInMonth = self.getDaysInMonth(month, year)
        secs = time.mktime( (year,month,1,0,0,0,0,0,-1) ) # first day of the month & year
        struct = time.localtime(secs)
        startPos = (struct.tm_wday + 1 ) % 7 # 0 - sunday for our needs instead 0 = monday in tm_wday
        slots = startPos + daysInMonth - 1
        rows = int(slots/7) + 1
        grid = Grid(rows+1, 7) # extra row for the days in the week
        grid.setWidth("100%")
        grid.addTableListener(self)
        self.middlePanel.setWidget(grid)
        #
        # put some content into the grid cells
        #
        for i in range(7):
            grid.setText(0, i, self.daysOfWeek[i] )
            grid.cellFormatter.addStyleName(0,i,"calendar-header")
        #
        # draw cells which are empty first
        #
        day =0
        pos = 0
        while pos < startPos:
            grid.setText(1, pos , " ")
            grid.cellFormatter.setStyleAttr(1,pos,"background","#f3f3f3")
            grid.cellFormatter.addStyleName(1,pos,"calendar-blank-cell")
            pos += 1
        # now for days of the month
        row = 1
        day = 1
        col = startPos
        while day <= daysInMonth:
            if pos % 7 == 0 and day <> 1:
                row += 1
            col = pos % 7
            grid.setText(row,col, str(day) )
            if self.currentYear == self.todayYear and self.currentMonth == self.todayMonth and day == self.todayDay:
                grid.cellFormatter.addStyleName(row,col,"calendar-cell-today")
            else:
                grid.cellFormatter.addStyleName(row,col,"calendar-day-cell")
            day += 1
            pos += 1
        #
        # now blank lines on the last row
        #
        col += 1
        while col < 7:
            grid.setText(row,col," ")
            grid.cellFormatter.setStyleAttr(row,col,"background","#f3f3f3")
            grid.cellFormatter.addStyleName(row,col,"calendar-blank-cell")
            col += 1

        return grid
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:57,代码来源:Calendar.py


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