From 6c8ddbd93c15e1df525fff43bba83e3329f79e8f Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sat, 21 Sep 2019 14:56:17 -0400 Subject: [PATCH] Updated to use the more "modern constructs". Changed how keys are named. --- DemoPrograms/Demo_Buttons_Nice_Graphics.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DemoPrograms/Demo_Buttons_Nice_Graphics.py b/DemoPrograms/Demo_Buttons_Nice_Graphics.py index 3242239f..78ae1b5b 100644 --- a/DemoPrograms/Demo_Buttons_Nice_Graphics.py +++ b/DemoPrograms/Demo_Buttons_Nice_Graphics.py @@ -29,29 +29,29 @@ def ShowMeTheButtons(): toolbar_buttons = [ [sg.Text('Who says Windows have to be ugly when using tkinter?', size=(45,3))], [sg.Text('All of these buttons are part of the code itself', size=(45,2))], - [sg.Button('Next', image_data=image_file_to_bytes(button64, (100,50)),button_color=wcolor, font='Any 15', pad=(0,0), key='_close_'), + [sg.Button('Next', image_data=image_file_to_bytes(button64, (100,50)),button_color=wcolor, font='Any 15', pad=(0,0), key='-NEXT-'), # [sg.Button('Exit', image_data=image_file_to_bytes(black64, (100,50)),button_color=bcolor, font='Any 15', pad=(0,0), key='_close_'),], - sg.Button('Submit', image_data=image_file_to_bytes(red_pill64, (100,50)),button_color=wcolor, font='Any 15', pad=(0,0), key='_close_'), - sg.Button('OK', image_data=image_file_to_bytes(green_pill64, (100,50)),button_color=bcolor, font='Any 15', pad=(0,0), key='_close_'), - sg.Button('Exit', image_data=image_file_to_bytes(orange64, (100,50)),button_color=bcolor, font='Any 15', pad=(0,0), key='_close_'),], + sg.Button('Submit', image_data=image_file_to_bytes(red_pill64, (100,50)),button_color=wcolor, font='Any 15', pad=(0,0), key='-SUBMIT-'), + sg.Button('OK', image_data=image_file_to_bytes(green_pill64, (100,50)),button_color=bcolor, font='Any 15', pad=(0,0), key='-OK-'), + sg.Button('Exit', image_data=image_file_to_bytes(orange64, (100,50)),button_color=bcolor, font='Any 15', pad=(0,0), key='-EXIT-'),], ] # layout = toolbar_buttons layout = [[sg.Frame('Nice Buttons', toolbar_buttons, font=('any 18'), background_color='black')]] - window = sg.Window('Demo of Nice Looking Buttons', + window = sg.Window('Demo of Nice Looking Buttons', layout, no_titlebar=False, grab_anywhere=True, keep_on_top=True, use_default_focus=False, font='any 15', - background_color='black').Layout(layout).Finalize() + background_color='black', finalize=True) # ---===--- Loop taking in user input --- # while True: - button, value = window.Read() - print(button) - if button == '_close_' or button is None: + event, values = window.Read() + print(event) + if event in ('-EXIT-', None): break # exit button clicked if __name__ == '__main__':