def __init__(self, height: int, width: int, font=None): super().__init__(height, width) self.font = font children_height = height // 7 self.month = TextWidget(children_height, width, self.font) self.month.row = 0 self.month.col = 0 self.add_child(self.month) days = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] cell_width = width // 7 for i, day in enumerate(days): day_text = TextWidget(children_height, cell_width, self.font) day_text.row = children_height day_text.col = i * cell_width day_text.text = day self.add_child(day_text) self.date_cells = [] for i in range(5): for j in range(7): day_text = TextWidget(children_height, cell_width, self.font) day_text.row = children_height * (i + 2) day_text.col = cell_width * j self.add_child(day_text) self.date_cells.append(day_text)
def __init__(self, height: int, width: int, icon_font: ImageFont, small_icon_font: ImageFont, text_font: ImageFont, icon_lookup: WeatherIconLookup) -> None: super().__init__(height, width) self.icon_lookup = icon_lookup self.weather_icon = TextWidget(height // 2, width // 2, font=icon_font) self.weather_icon.row = 0 self.weather_icon.col = 0 self.weather_icon.text = icon_lookup.look_up_with_name('wi-na') self.add_child(self.weather_icon) detail_width = width * 0.2 self.temperature_icon = TextWidget(height // 4, width // 4, font=small_icon_font) self.temperature_icon.row = 0 self.temperature_icon.col = width // 2 self.temperature_icon.text = icon_lookup.look_up_with_name( 'wi-thermometer') self.add_child(self.temperature_icon) self.temperature_text = TextWidget(height // 4, width // 4, font=text_font) self.temperature_text.row = 0 self.temperature_text.col = width // 4 * 3 self.temperature_text.text = '--' self.add_child(self.temperature_text) self.humidity_icon = TextWidget(height // 4, width // 4, font=small_icon_font) self.humidity_icon.row = height // 4 self.humidity_icon.col = width // 2 self.humidity_icon.text = icon_lookup.look_up_with_name('wi-humidity') self.add_child(self.humidity_icon) self.humidity_text = TextWidget(height // 4, width // 4, font=text_font) self.humidity_text.row = height // 4 self.humidity_text.col = width // 4 * 3 self.humidity_text.text = '--' self.add_child(self.humidity_text) self.forecasts: List[ForecastWidget] = [] for i in range(4): forecast = ForecastWidget(height // 2, width // 4, small_icon_font, text_font, icon_lookup) forecast.row = height // 2 forecast.col = i * width // 4 self.add_child(forecast) self.forecasts.append(forecast)
def __init__(self, height: int, width: int, icon_font: ImageFont, text_font: ImageFont, icon_lookup: WeatherIconLookup): super().__init__(height, width) self.weather_icon = TextWidget(height // 2, width, font=icon_font) self.weather_icon.row = 0 self.weather_icon.col = 0 self.weather_icon.text = icon_lookup.look_up_with_name('wi-na') self.add_child(self.weather_icon) self.high_temp_text = TextWidget(height // 4, width, font=text_font) self.high_temp_text.row = height // 2 self.high_temp_text.col = 0 self.high_temp_text.text = '--' self.add_child(self.high_temp_text) self.low_temp_text = TextWidget(height // 4, width, font=text_font) self.low_temp_text.row = height // 4 * 3 self.low_temp_text.col = 0 self.low_temp_text.text = '--' self.add_child(self.low_temp_text) self.icon_lookup = icon_lookup
def __init__(self, height: int, width: int, header_font: ImageFont, event_font: ImageFont) -> None: super().__init__(height, width) header = TextWidget(height // 10, width, font=header_font) header.row = 0 header.col = 0 header.text = 'Events' header.foreground = self.background header.background = self.foreground header.is_draw_border(True) self.add_child(header) event_top = height // 5 self.event_widgets = [] while event_top < self.width: event = EventWidget(height // 10, width, event_font=event_font) event.row = event_top event.col = 0 self.event_widgets.append(event) self.add_child(event) event_top += height // 10