Format subtitle to current/next Wednesday
This commit is contained in:
		
							parent
							
								
									d790f56785
								
							
						
					
					
						commit
						bc0d239a1f
					
				
							
								
								
									
										12
									
								
								hcatitles.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								hcatitles.py
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | |||||||
| import os | import os | ||||||
| import PySimpleGUI as sg | import PySimpleGUI as sg | ||||||
|  | from datetime import date, timedelta | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from PIL import Image, ImageDraw, ImageEnhance, ImageFilter, ImageFont, ImageOps | from PIL import Image, ImageDraw, ImageEnhance, ImageFilter, ImageFont, ImageOps | ||||||
| from io import BytesIO | from io import BytesIO | ||||||
| @ -20,6 +21,15 @@ def save_filename(): | |||||||
|         return folder / 'Title.png' |         return folder / 'Title.png' | ||||||
|     return Path.home() / 'Pictures' / 'Title.png' |     return Path.home() / 'Pictures' / 'Title.png' | ||||||
| 
 | 
 | ||||||
|  | def get_subtitle(): | ||||||
|  |     """find Wednesday of the current/next week""" | ||||||
|  |     today = date.today() | ||||||
|  |     if today.weekday() > 2: | ||||||
|  |         wednesday = today + tiemdelta(9 - today.weekday()) | ||||||
|  |     else: | ||||||
|  |         wednesday = today + timedelta(2 - today.weekday()) | ||||||
|  |     return wednesday.strftime('Bible Study %A %B %#d, %Y') | ||||||
|  | 
 | ||||||
| def update_image(original, title, subtitle): | def update_image(original, title, subtitle): | ||||||
|     """Render new title and title preview |     """Render new title and title preview | ||||||
|     renders text on full sized slide |     renders text on full sized slide | ||||||
| @ -93,7 +103,7 @@ def build_layout(title, subtitle, thumbnail): | |||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
|     title = 'Pastor Shane Wallis' |     title = 'Pastor Shane Wallis' | ||||||
|     subtitle = 'Bible Stduy Wednesday June 1st, 2022' |     subtitle = get_subtitle() | ||||||
|     image_path = resource_path('blank_title.png') |     image_path = resource_path('blank_title.png') | ||||||
|     original = Image.open(image_path) |     original = Image.open(image_path) | ||||||
|     image = update_image(original, title, subtitle) |     image = update_image(original, title, subtitle) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user