Improve positions
This commit is contained in:
parent
cac484840e
commit
af4730a964
@ -239,7 +239,8 @@ class WeeklyWeatherModule:
|
|||||||
def draw_module(self, config, width, height):
|
def draw_module(self, config, width, height):
|
||||||
image = Image.new('RGB', (width, height), 'white')
|
image = Image.new('RGB', (width, height), 'white')
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
fnt_R = ImageFont.truetype(config.fnt_R_path, 12)
|
fnt_R = ImageFont.truetype(config.fnt_R_path, 14)
|
||||||
|
fnt_B = ImageFont.truetype(config.fnt_RB_path, 14)
|
||||||
|
|
||||||
weekweather = WeatherAPI().get_daily()
|
weekweather = WeatherAPI().get_daily()
|
||||||
daysweather = weekweather["data"]
|
daysweather = weekweather["data"]
|
||||||
@ -247,10 +248,11 @@ class WeeklyWeatherModule:
|
|||||||
nbdays = len(daysweather[self.first_day:self.first_day+self.limit_futur])
|
nbdays = len(daysweather[self.first_day:self.first_day+self.limit_futur])
|
||||||
day_size = int(height / (nbdays + 1))
|
day_size = int(height / (nbdays + 1))
|
||||||
|
|
||||||
draw.text(
|
display_longtext(draw,
|
||||||
(day_size + 3, day_size / 2),
|
(day_size + (width - day_size)/2, day_size / 2 + 5),
|
||||||
"%s" % (weekweather["summary"]),
|
weekweather["summary"],
|
||||||
fill="black", anchor="lm", font=fnt_R
|
fill="black", anchor="mm", font=fnt_B,
|
||||||
|
maxwidth=width - day_size
|
||||||
)
|
)
|
||||||
|
|
||||||
temp = []
|
temp = []
|
||||||
@ -271,10 +273,16 @@ class WeeklyWeatherModule:
|
|||||||
"%d˚" % math.trunc(day["temperatureLow"]),
|
"%d˚" % math.trunc(day["temperatureLow"]),
|
||||||
fill="black", anchor="rt", font=fnt_R
|
fill="black", anchor="rt", font=fnt_R
|
||||||
)
|
)
|
||||||
|
summary_size = fnt_R.getsize(WeatherAPI().read_timestamp(day["time"]).strftime("%a") + " : " + day["summary"])[0]
|
||||||
draw.text(
|
draw.text(
|
||||||
(day_size + (width - day_size) / 2, (i + 1) * day_size - 4),
|
(day_size + (width - day_size - summary_size) / 2, (i + 1) * day_size - 6),
|
||||||
|
WeatherAPI().read_timestamp(day["time"]).strftime("%a") + " : ",
|
||||||
|
fill="#666", anchor="ls", font=fnt_R
|
||||||
|
)
|
||||||
|
draw.text(
|
||||||
|
(day_size + (width - day_size + summary_size) / 2, (i + 1) * day_size - 6),
|
||||||
day["summary"],
|
day["summary"],
|
||||||
fill="black", anchor="mb", font=fnt_R
|
fill="black", anchor="rs", font=fnt_R
|
||||||
)
|
)
|
||||||
draw.text(
|
draw.text(
|
||||||
(day_size + int((day["temperatureHigh"]-t_min)*t_scale) + 2, i * day_size + 4),
|
(day_size + int((day["temperatureHigh"]-t_min)*t_scale) + 2, i * day_size + 4),
|
||||||
|
Loading…
Reference in New Issue
Block a user