本文整理汇总了Python中Grid.Grid.addTableListener方法的典型用法代码示例。如果您正苦于以下问题:Python Grid.addTableListener方法的具体用法?Python Grid.addTableListener怎么用?Python Grid.addTableListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid.Grid
的用法示例。
在下文中一共展示了Grid.addTableListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawGrid
# 需要导入模块: from Grid import Grid [as 别名]
# 或者: from Grid.Grid import addTableListener [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
示例2: UserList
# 需要导入模块: from Grid import Grid [as 别名]
# 或者: from Grid.Grid import addTableListener [as 别名]
class UserList(AbsolutePanel):
userGrid = None
newBtn = None
deleteBtn = None
users = None
selectedUser = None
def __init__(self,parent):
AbsolutePanel.__init__(self)
self.userGrid = Grid()
self.userGrid.createGrid(6, 6)
self.userGrid.addTableListener(self)
self.userGrid.setBorderWidth(2)
self.userGrid.setCellPadding(4)
self.userGrid.setCellSpacing(1)
self.userGrid.setColLabelValue(0,"Username")
self.userGrid.setColLabelValue(1,"First Name")
self.userGrid.setColLabelValue(2,"Last Name")
self.userGrid.setColLabelValue(3,"Email")
self.userGrid.setColLabelValue(4,"Department")
self.userGrid.setColLabelValue(5,"Password")
self.newBtn = Button("New")
self.deleteBtn = Button("Delete")
self.deleteBtn.setEnabled(False)
self.add(self.userGrid)
self.add(self.newBtn)
self.add(self.deleteBtn)
return
def updateUserGrid(self, users):
self.userGrid.clearGrid()
self.users = users
for i in range(len(users)):
self.userGrid.setCellValue(i, 0, users[i].username)
self.userGrid.setCellValue(i, 1, users[i].fname)
self.userGrid.setCellValue(i, 2, users[i].lname)
self.userGrid.setCellValue(i, 3, users[i].email)
self.userGrid.setCellValue(i, 4, users[i].department)
self.userGrid.setCellValue(i, 5, users[i].password)
def onCellClicked(self, sender, row, col):
try:
if row > 0 and row <= len(self.users):
self.selectedUser = self.users[row-1]
self.userGrid.selectRow(row)
self.deleteBtn.setEnabled(True)
else:
self.userGrid.selectRow(-1)
self.selectedUser = None
self.deleteBtn.setEnabled(False)
except IndexError:
pass
def deSelect(self):
self.userGrid.selectRow(-1)