From e3338fc3f61aab31754cb9eecf1e2d328864fbd0 Mon Sep 17 00:00:00 2001 From: Tim Meneely Date: Tue, 26 May 2026 15:14:50 +0000 Subject: [PATCH] Cleaned up messyness --- .gitignore | 1 + imagegen.py | 17 ++--------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index b4c7e58..942ef47 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ old Scripts pyvenv.cfg share +*.swp diff --git a/imagegen.py b/imagegen.py index b9bafb1..2872318 100644 --- a/imagegen.py +++ b/imagegen.py @@ -11,9 +11,7 @@ fntBigBold = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bol def WriteTextBlock(text, context, font = fnt, column=0, row=0, anchor = "la"): context.multiline_text((column, row), text, font=font, fill=0, anchor = anchor) - #boundingBox = ImageDraw.textbbox(xy, text, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, embedded_color=False, font_size=None) boundingBox = context.multiline_textbbox((column,row),text,font=font,anchor=anchor) - print("boundingBox",boundingBox,"newrow",boundingBox[3]) return boundingBox[3] # create an image @@ -32,35 +30,24 @@ d = ImageDraw.Draw(out) # create text txt1 = datetime.datetime.now(pytz.timezone('America/New_York')).strftime('%A %B %d, %Y') # draw multiline text -#d.multiline_text((displaysize[0]/2, row), txt1, font=fntBigBold, fill=0, anchor = "ma") #, align="center") row = WriteTextBlock(txt1,d,fntBigBold,displaysize[0]/2,row,"ma") -#row += HeightBold txt1a = "As of "+datetime.datetime.now(pytz.timezone('America/New_York')).strftime('%I:%M %p') -#d.multiline_text((displaysize[0]/2, row), txt1a, font=fnt, fill=0, anchor = "ma") #, align="center") row = WriteTextBlock(txt1a,d,fnt,displaysize[0]/2,row,"ma") -#row += HeightNormal -#d.multiline_text((MarginLeft, row), "Weather:", font=fnt, fill=0, anchor = "la") -#row += HeightNormal row = WriteTextBlock("Weather",d,fnt,MarginLeft,row,"la") try: - weather = "" #google_weather.get_google_weather() + weather = google_weather.get_google_weather() txt2 = "Current: "+weather["current"] \ +"\nToday's forecast: "+weather["forecast_today"] \ +"\nTomorrow: "+weather["forecast_tomorrow"] except: # Assume the weather API blew up txt2 = "Problem getting weather (from ImageGen)" row = WriteTextBlock(txt2,d,fnt,MarginIndent,row,"la") -#d.multiline_text((MarginIndent, row), txt2, font=fnt, fill=0, anchor = "la") -#row += 3*HeightNormal -#d.multiline_text((MarginLeft,row), "Pirates:", font=fnt, fill=0, anchor = "la") -#row += HeightNormal row = WriteTextBlock("Pirates",d,fnt,MarginLeft,row,"la") -#d.multiline_text((MarginIndent,row), mlb.get_pirates(), font=fnt, fill=0, anchor = "la")# row = WriteTextBlock(mlb.get_pirates(),d,fnt,MarginIndent,row,"la") -##row += 3*HeightNormal + row = WriteTextBlock("========== End =========",d,fnt,MarginLeft,row,"la") out.save("/mnt/nfs/HomeAutomation/ForHA.jpg","JPEG")