From a462f169e44fc9c63b43b7c1ba9daac625671730 Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Sun, 29 May 2022 18:33:32 -0700 Subject: [PATCH] refactor image processing out of layout --- hcatitles.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hcatitles.py b/hcatitles.py index 5163221..63fbffa 100644 --- a/hcatitles.py +++ b/hcatitles.py @@ -28,9 +28,7 @@ def update_thumbnail(image): return thumbnail -def build_layout(image_path): - title = 'Pastor Shane Wallis' - subtitle = 'Bible Stduy Wednesday June 1st, 2022' +def build_layout(title, subtitle, thumbnail): control_col = sg.Column([ [ sg.Frame('Title', @@ -43,9 +41,7 @@ def build_layout(image_path): [ sg.Button('Save image', key= '-SAVE-')], ]) - original = Image.open(image_path) - image = update_image(original, title, subtitle) - thumbnail = update_thumbnail(image) + bio = BytesIO() thumbnail.save(bio, format = 'PNG') image_col = sg.Column([[sg.Image(data=bio.getvalue(), key = '-IMAGE-')]]) @@ -53,9 +49,14 @@ def build_layout(image_path): return layout def main(): + title = 'Pastor Shane Wallis' + subtitle = 'Bible Stduy Wednesday June 1st, 2022' image_path = 'blank_title.png' original = Image.open(image_path) - layout = build_layout(image_path) + image = update_image(original, title, subtitle) + thumbnail = update_thumbnail(image) + + layout = build_layout(title, subtitle, thumbnail) window = sg.Window('Harvest Christian Assembly Message Title', layout) while True: