コード例 #1
0
 def __draw_day_number__(self, number, pos):
     if number <= 0:
         return
     txt = TextDesign(self.__abs_pos__(daynumberboxsize), fontsize=daynumbersize *
                      self.size[0], text=str(number), verticalalignment="center", horizontalalignment="center")
     txt.pos = (pos[0], pos[1] + day_number_ypadding * self.size[1])
     self.draw_design(txt)
コード例 #2
0
    def __draw_event_block__(self, pos, size, event):
        box_color = colors["hl"] if event.highlight else colors["fg"]
        box = BoxDesign(size, fill=box_color)
        box.mask = False
        box.pos = pos
        self.draw_design(box)

        text = event.title
        text_color = colors["bg"]
        textbox_size = (size[0] - event_title_xpadding,
                        size[1] - event_title_ypadding)
        txt = TextDesign(textbox_size,
                         text=text,
                         font=event_title_font,
                         fontsize=event_title_fontsize,
                         color=text_color,
                         background_color=box_color,
                         wrap=True)
        txt.mask = False
        txt.pos = (pos[0] + event_title_xpadding,
                   pos[1] + event_title_ypadding)
        self.draw_design(txt)

        half_ypadding = int(event_title_ypadding / 2)
        line_start = (pos[0] + event_title_xpadding, pos[1] + half_ypadding)
        line_end = (pos[0] + size[0] - event_title_xpadding,
                    pos[1] + half_ypadding)
        ImageDraw.Draw(self.__image__).line([line_start, line_end],
                                            fill=colors["bg"],
                                            width=1)
コード例 #3
0
 def __draw_text__(self, text, pos, size):
     txt = TextDesign(size,
                      fontsize=18,
                      text=text,
                      verticalalignment="center",
                      horizontalalignment="center")
     txt.pos = pos
     self.draw_design(txt)
コード例 #4
0
 def __draw_month_name__(self):
     """Draw the icon with the current month's name"""
     month = datetime.now().strftime("%B")
     txt = TextDesign(self.__abs_pos__(monthboxsize),
                      fontsize=monthtextsize * self.size[1],
                      text=month,
                      verticalalignment="center",
                      horizontalalignment="center")
     pos = self.__abs_pos__(monthplace)
     txt.pos = (pos[0], pos[1] + self.weather_header_height)
     self.draw_design(txt)
コード例 #5
0
    def __draw_month__(self):
        font_size = int(month_height * self.size[1])
        xpadding = int(monthbox_xpadding * self.size[0])
        ypadding = int(monthbox_ypadding * self.size[1])
        box_ypos = int(numberbox_ypos * self.size[1])
        box_height = int(numberbox_height * self.size[1])
        box_pos = (box_ypos + box_height + xpadding, box_ypos + ypadding)
        box_size = (int(monthbox_width * self.size[0]), box_height)

        month_name = self.date.strftime("%B")
        month = TextDesign(box_size, text=month_name, fontsize=font_size)
        month.pos = box_pos
        self.draw_design(month)
コード例 #6
0
    def __draw_week_row__(self):
        for day_of_week, day in enumerate(self.__week_days__):
            txt = TextDesign(self.__abs_pos__(weekrownameboxsize),
                             fontsize=weekdaytextsize * self.size[1],
                             text=str(day),
                             verticalalignment="center",
                             horizontalalignment="center")
            pos = self.__get_week_day_pos__(day_of_week)
            txt.pos = (pos[0], pos[1] + weekdaytextpadding * self.size[1])
            self.draw_design(txt)

        self.__draw_highlight_box__(self.__abs_pos__(weekrownameboxsize),
                                    self.__get_week_day_pos__(
                                        self.__get_day_of_week__(
                                            datetime.now())),
                                    width=1)
コード例 #7
0
    def __draw_text__(self, pos, size, row, col):
        color = self.__get_cell_prop__(row, col, "color")
        bg_color = self.__get_cell_prop__(row, col, "background_color")
        fontsize = self.__get_cell_prop__(row, col, "font-size")

        design = TextDesign(
            size,
            text=self.matrix[row][col],
            font=self.font_family,
            color=color,
            background_color=bg_color,
            fontsize=fontsize,
            horizontalalignment=self.__get_col_hori_alignment__(col),
            wrap=self.wrap,
            truncate=self.truncate_text,
            truncate_suffix=self.truncate_suffix)
        design.pos = pos
        design.mask = False
        self.draw_design(design)
コード例 #8
0
    def __draw_day_number__(self):
        font_size = int(daynumber_fontsize * self.size[1])
        ypadding = daynumber_ypadding * self.size[1]
        size = (daynumber_y_size[0] * self.size[1],
                daynumber_y_size[1] * self.size[1])
        pos = (0, ypadding)

        day_text = self.__get_day_text__()
        color = self.__get_day_color__()

        number = TextDesign(size,
                            text=day_text,
                            font=font,
                            color=color,
                            fontsize=font_size,
                            horizontalalignment="center",
                            verticalalignment="bottom")
        number.pos = pos
        self.draw_design(number)
コード例 #9
0
    def __draw_weekday__(self):
        font_size = weekday_height * self.size[1]
        box_height = numberbox_height * self.size[1]
        size = (box_height, weekdaybox_height * box_height)
        box_ypos = numberbox_ypos * self.size[1]
        pos = (box_ypos, box_ypos)

        week_day_name = self.date.strftime("%A")
        week_day = TextDesign(size,
                              text=week_day_name,
                              background_color=numberbox_background_color,
                              color=numberbox_font_color,
                              fontsize=font_size,
                              horizontalalignment="center",
                              verticalalignment="center",
                              font=weekday_font)
        week_day.pos = pos
        week_day.mask = False
        self.draw_design(week_day)
コード例 #10
0
    def __draw_today_number__(self):
        font_size = number_height * self.size[1]
        box_height = numberbox_height * self.size[1]
        box_ypos = numberbox_ypos * self.size[1]
        ypadding = number_boxypos * box_height
        size = (box_height, box_height - ypadding)
        pos = (box_ypos, box_ypos + ypadding)

        day_text = self.__get_day_text__()
        number = TextDesign(size,
                            text=day_text,
                            background_color=numberbox_background_color,
                            color=numberbox_font_color,
                            fontsize=font_size,
                            horizontalalignment="center",
                            verticalalignment="center")
        number.pos = pos
        number.mask = False
        self.draw_design(number)
コード例 #11
0
    def __draw_weekday__(self):
        font_size = int(weekday_fontsize * self.size[1])
        size = (weekday_y_size[0] * self.size[1],
                weekday_y_size[1] * self.size[1])
        ypos = weekday_ypos * self.size[1]
        pos = (0, ypos)

        color = self.__get_day_color__()
        week_day_name = self.date.strftime("%a")

        week_day = TextDesign(size,
                              text=week_day_name,
                              font=font,
                              color=color,
                              fontsize=font_size,
                              horizontalalignment="center",
                              verticalalignment="top")
        week_day.pos = pos
        week_day.mask = False
        self.draw_design(week_day)
コード例 #12
0
    def __draw_row__(self, hour):
        subtext_height = self.row_size[1] * hoursubtext_height
        sub_fontsize = subtext_height * hoursubtext_fontsize
        ypadding = hour_ypadding * self.row_size[1]
        width = hourbox_y_width * self.row_size[1]
        height = self.row_size[1] - subtext_height
        size = (width, height)
        pos = (0, self.__get_ypos_for_time__(hour) + ypadding)
        fontsize = size[1] * hour_box_fontsize

        txt = TextDesign(size,
                         text=self.__get_hour_text__(hour),
                         fontsize=fontsize,
                         verticalalignment="bottom",
                         horizontalalignment="center")
        txt.pos = pos
        self.draw_design(txt)

        sub = TextDesign((width, subtext_height),
                         text=self.__get_hour_sub_text__(hour),
                         fontsize=sub_fontsize,
                         verticalalignment="top",
                         horizontalalignment="center")
        sub.pos = (0, height + self.__get_ypos_for_time__(hour))
        self.draw_design(sub)
コード例 #13
0
    def __finish_image__(self):
        data = self.__get_data__()

        txt = TextDesign(self.size, text=data, fontsize=font_size)
        txt.color = colors["fg"]
        txt.pos = (0, 0)
        self.draw_design(txt)

        txt = TextDesign(self.size, text=data, fontsize=font_size)
        txt.color = colors["hl"]
        txt.pos = (1, 1)
        self.draw_design(txt)

        txt = TextDesign(self.size, text=data, fontsize=font_size)
        txt.color = colors["fg"]
        txt.pos = (2, 2)
        self.draw_design(txt)