refactor image processing out of layout

This commit is contained in:
Fredrick W. Warren 2022-05-29 18:33:32 -07:00
parent b896476cd2
commit a462f169e4

View File

@ -28,9 +28,7 @@ def update_thumbnail(image):
return thumbnail return thumbnail
def build_layout(image_path): def build_layout(title, subtitle, thumbnail):
title = 'Pastor Shane Wallis'
subtitle = 'Bible Stduy Wednesday June 1st, 2022'
control_col = sg.Column([ control_col = sg.Column([
[ [
sg.Frame('Title', sg.Frame('Title',
@ -43,9 +41,7 @@ def build_layout(image_path):
[ [
sg.Button('Save image', key= '-SAVE-')], sg.Button('Save image', key= '-SAVE-')],
]) ])
original = Image.open(image_path)
image = update_image(original, title, subtitle)
thumbnail = update_thumbnail(image)
bio = BytesIO() bio = BytesIO()
thumbnail.save(bio, format = 'PNG') thumbnail.save(bio, format = 'PNG')
image_col = sg.Column([[sg.Image(data=bio.getvalue(), key = '-IMAGE-')]]) image_col = sg.Column([[sg.Image(data=bio.getvalue(), key = '-IMAGE-')]])
@ -53,9 +49,14 @@ def build_layout(image_path):
return layout return layout
def main(): def main():
title = 'Pastor Shane Wallis'
subtitle = 'Bible Stduy Wednesday June 1st, 2022'
image_path = 'blank_title.png' image_path = 'blank_title.png'
original = Image.open(image_path) 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) window = sg.Window('Harvest Christian Assembly Message Title', layout)
while True: while True: