Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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