Ejemplo n.º 1
0
 def set_year(self, year):
     """Fills in date numbers and colours background of brews and searched
     for dates"""
     year_instance = Year(year)
     months = year_instance.get_months()
     today = False
     colour = Qt.QColor('black')
     if year_instance.get_today():
         today = year_instance.get_today()
     for month_num in range(12):
         curr_month = month_num
         month = months[month_num]
         for date in range(len(month)):
             curr_date = date
             date = month[date]
             item = self.item(curr_month, curr_date)
             item_text = str(date)
             if item is not None:
                 if item.child(0, 0) == True:
                     # Is a brew
                     item.setBackground(self.colourSettings.brewday_col)
                 if item.child(0, 1).data == True:
                     # Identified in search
                     item.setBackground(self.colourSettings.searchday_col)
                 # Set text
                 if today:
                     if today[0] == curr_date and today[1] == curr_month:
                         # Highlight today
                         colour = Qt.QColor('red')
                         item.setFont(QFont('Sans Serif', 15, QFont.Bold))
                     else:
                         colour = Qt.QColor('black')
                 item.setForeground(colour)
                 item.setText(item_text)
                 item.setTextAlignment(Qt.Qt.AlignCenter)
                 # Make the QDate a child of the day
                 if date is not '':
                     date = int(date)
                     now = QDate(year, curr_month + 1, date)
                     date = QStandardItem()
                     item.setChild(0, 1, date)
                     date.setData(now)