From d2f4da510524fba40cf53e0193e828e81538ca2f Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 5 Dec 2018 11:28:20 -0500 Subject: [PATCH] Make portable to Qt. Collapsed definition using Lambda --- DemoPrograms/Demo_Media_Player.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/DemoPrograms/Demo_Media_Player.py b/DemoPrograms/Demo_Media_Player.py index 4ccd84bd..3d8dee6f 100644 --- a/DemoPrograms/Demo_Media_Player.py +++ b/DemoPrograms/Demo_Media_Player.py @@ -2,6 +2,7 @@ import sys if sys.version_info[0] >= 3: import PySimpleGUI as sg + # import PySimpleGUIQt as sg # portable to QT else: import PySimpleGUI27 as sg @@ -23,31 +24,18 @@ def MediaPlayerGUI(): # A text element that will be changed to display messages in the GUI + ImageButton = lambda key:sg.Button('', button_color=(background,background), image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0, key=key) # define layout of the rows layout= [[sg.Text('Media File Player',size=(17,1), font=("Helvetica", 25))], [sg.Text('', size=(15, 2), font=("Helvetica", 14), key='output')], - [sg.Button('', button_color=(background,background), - image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0, key='Restart Song'), + [ImageButton(key='Restart Song'), sg.Text(' ' * 2), + ImageButton(key='Pause'), sg.Text(' ' * 2), - sg.Button('', button_color=(background,background), - image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0, key='Pause'), + ImageButton(key='Next'), sg.Text(' ' * 2), - sg.Button('', button_color=(background,background), image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0, key='Next'), - sg.Text(' ' * 2), - sg.Text(' ' * 2), sg.Button('', button_color=(background,background), - image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0, key='Exit')], + sg.Text(' ' * 2),ImageButton(key='Exit')], [sg.Text('_'*20)], - [sg.Text(' '*30)], - [ - sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)), - sg.Text(' ' * 2), - sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)), - sg.Text(' ' * 2), - sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15))], - [sg.Text(' Bass', font=("Helvetica", 15), size=(9, 1)), - sg.Text('Treble', font=("Helvetica", 15), size=(7, 1)), - sg.Text('Volume', font=("Helvetica", 15), size=(7, 1))] ] # Open a form, note that context manager can't be used generally speaking for async forms