From 3b00d39c3abe5ea885ab04239acdcffc74e7ff88 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Tue, 25 May 2021 14:16:21 -0400 Subject: [PATCH] Improvements to the newer PIL demos --- DemoPrograms/Demo_PIL_Rounded_Rectangle_Buttons.py | 13 ++++++------- DemoPrograms/Demo_PIL_Toggle_Button.py | 7 ++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/DemoPrograms/Demo_PIL_Rounded_Rectangle_Buttons.py b/DemoPrograms/Demo_PIL_Rounded_Rectangle_Buttons.py index 872ee54a..de615b5e 100644 --- a/DemoPrograms/Demo_PIL_Rounded_Rectangle_Buttons.py +++ b/DemoPrograms/Demo_PIL_Rounded_Rectangle_Buttons.py @@ -60,17 +60,16 @@ def rounded_rectangle(text, font=('arial.ttf', 14), button_color=None,): return im_to_data(im) -sg.theme("dark red") -# sg.theme("dark green 7") +# sg.theme("dark red") +sg.theme("dark green 7") # sg.set_options(font=("Arial", 16)) layout = [[sg.Button('Normal Button')], [sg.Button('', image_data=sg.EMOJI_BASE64_HAPPY_THUMBS_UP, border_width=0, button_color=(sg.theme_background_color(), sg.theme_background_color()))], - [sg.Button(image_data=rounded_rectangle('Button text\nwith 2 lines', font=('cour.ttf', 15)), button_color=(sg.theme_background_color(), sg.theme_background_color()), border_width=0)]] - # [sg.Button(image_data=rounded_rectangle('Button text\nwith 2 lines', font=('cour.ttf', 15)), button_color=(sg.theme_background_color(), sg.theme_background_color()), border_width=0)]] - + [sg.Button(image_data=rounded_rectangle('Button text\nwith 2 lines', font=('arial.ttf', 25)), button_color=(sg.theme_background_color(), sg.theme_background_color()), border_width=0)]] + layout += [ [sg.Button( - image_data=rounded_rectangle(text, font=('cour.ttf', 15)), + image_data=rounded_rectangle(text, font=('cour.ttf', 25)), button_color=(sg.theme_button_color()[0], sg.theme_background_color()), border_width=0)] for text in ( @@ -80,7 +79,7 @@ layout += [ "123\n2\n3") ] -window = sg.Window('Image and Rounded Button', layout, finalize=True) +window = sg.Window('Image and Rounded Button', layout, finalize=True, keep_on_top=True, use_custom_titlebar=True) while True: diff --git a/DemoPrograms/Demo_PIL_Toggle_Button.py b/DemoPrograms/Demo_PIL_Toggle_Button.py index db16422b..7ba97db8 100644 --- a/DemoPrograms/Demo_PIL_Toggle_Button.py +++ b/DemoPrograms/Demo_PIL_Toggle_Button.py @@ -65,7 +65,7 @@ layout = [[sg.T('PIL Made Toggle Buttons')], [sg.Button(image_data=button_off, button_color=(sg.theme_background_color(), sg.theme_background_color()), border_width=0, k='-B2-', metadata=False)]] -window = sg.Window('PIL Buttons', layout, finalize=True, element_justification='c', use_custom_titlebar=True, font='_ 18') +window = sg.Window('PIL Buttons', layout, finalize=True, element_justification='c', use_custom_titlebar=True, font='_ 18', keep_on_top=True) while True: @@ -73,9 +73,6 @@ while True: if event in (sg.WINDOW_CLOSED, "Exit"): break window[event].metadata = not window[event].metadata - if window[event].metadata: - window[event].update(image_data=button_on) - else: - window[event].update(image_data=button_off) + window[event].update(image_data=button_on if window[event].metadata else button_off) window.close()