def showday(self, year, month, day, rowtoshow=-1): """Ensures specified date is onscreen @param rowtoshow: if is >=0 then it will be forced to appear in that row """ # check first cell y,m,d=self.rows[0][0].year, self.rows[0][0].month, self.rows[0][0].day if rowtoshow==-1: if year<y or (year<=y and month<m) or (year<=y and month<=m and day<d): rowtoshow=0 # check last cell y,m,d=self.rows[-1][-1].year, self.rows[-1][-1].month, self.rows[-1][-1].day if rowtoshow==-1: if year>y or (year>=y and month>m) or (year>=y and month>=m and day>d): rowtoshow=self.numrows-1 if rowtoshow!=-1: d=calendar.weekday(year, month, day) d=(d+1)%7 d=day-d # go back to begining of week d-=7*rowtoshow # then begining of screen y,m,d=normalizedate(year, month, d) for row in range(0,self.numrows): self.updaterow(row, *normalizedate(y, m, d+7*row)) self.label.changenotify() self.ensureallpainted()
def showday(self, year, month, day, rowtoshow=-1): """Ensures specified date is onscreen @param rowtoshow: if is >=0 then it will be forced to appear in that row """ # check first cell y, m, d = self.rows[0][0].year, self.rows[0][0].month, self.rows[0][ 0].day if rowtoshow == -1: if year < y or (year <= y and month < m) or (year <= y and month <= m and day < d): rowtoshow = 0 # check last cell y, m, d = self.rows[-1][-1].year, self.rows[-1][-1].month, self.rows[ -1][-1].day if rowtoshow == -1: if year > y or (year >= y and month > m) or (year >= y and month >= m and day > d): rowtoshow = self.numrows - 1 if rowtoshow != -1: d = calendar.weekday(year, month, day) d = (d + 1) % 7 d = day - d # go back to begining of week d -= 7 * rowtoshow # then begining of screen y, m, d = normalizedate(year, month, d) for row in range(0, self.numrows): self.updaterow(row, *normalizedate(y, m, d + 7 * row)) self.label.changenotify() self.ensureallpainted()
def setselection(self, year, month, day): """Selects the specifed date if it is visible""" self.selecteddate=(year,month,day) d=calendar.weekday(year, month, day) d=(d+1)%7 for row in range(0, self.numrows): cell=self.rows[row][d] if cell.year==year and cell.month==month and cell.day==day: self._unselect() self.rows[row][d].setattr(self.attrselectedcell) self.selectedcell=(row,d) self.ensureallpainted() return
def setselection(self, year, month, day): """Selects the specifed date if it is visible""" self.selecteddate = (year, month, day) d = calendar.weekday(year, month, day) d = (d + 1) % 7 for row in range(0, self.numrows): cell = self.rows[row][d] if cell.year == year and cell.month == month and cell.day == day: self._unselect() self.rows[row][d].setattr(self.attrselectedcell) self.selectedcell = (row, d) self.ensureallpainted() return