From 3d1fe8bf28a7ae8165b07f5f8f7bc0bf581543a8 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Mon, 30 Aug 2021 16:06:45 -0400 Subject: [PATCH] Reworked the old "expasion" demo and used Stretch elements instead of expanding Text elements. Renamed the demo to have the word stretch in the name. --- .../Demo_Justification_Using_Expansion.py | 37 ------------------- ...mo_Justification_Using_Stretch_Elements.py | 36 ++++++++++++++++++ 2 files changed, 36 insertions(+), 37 deletions(-) delete mode 100644 DemoPrograms/Demo_Justification_Using_Expansion.py create mode 100644 DemoPrograms/Demo_Justification_Using_Stretch_Elements.py diff --git a/DemoPrograms/Demo_Justification_Using_Expansion.py b/DemoPrograms/Demo_Justification_Using_Expansion.py deleted file mode 100644 index b22e6ab7..00000000 --- a/DemoPrograms/Demo_Justification_Using_Expansion.py +++ /dev/null @@ -1,37 +0,0 @@ -import PySimpleGUI as sg - -""" - Demo Element Justification In A Window Using A Text Element That Expands - - How to Justify elements on 1 row to be left, right or left, middle, right - - Additionally, locate these buttons at the bottom of the screen - - The key concepts to use are the newly added expand_x and expand_y - - To get 2 buttons to be all the way to the left and to the far right, then - you want to place a text element between them that expands - If you want a third button that is centered, then add TWO Text elements, one - on each side of the middle one - - Copyright 2021 PySimpleGUI -""" - - -layout = [ [sg.Text('Window with elements on the left and the right')], - [sg.T('Using a text element that expands enables you to "push" other elements around')], - [sg.HorizontalSeparator()], - [sg.T(expand_y=True, pad=(0,0), font='_ 1')], # Take as little room as possible - [sg.Button('Left'), sg.Text(expand_x=True, pad=(0,0)), sg.Button('Right')], - [sg.Text(expand_x=True), sg.B('Right')], - [sg.Button('Left'), sg.Text(expand_x=True, pad=(0,0)), sg.B('Middle'), sg.Text(expand_x=True, pad=(0,0)), sg.Button('Right')] ] - -window = sg.Window('Left and Right Justification', layout, resizable=True) - -while True: - event, values = window.read() - print(event, values) - if event == sg.WIN_CLOSED or event == 'Exit': - break - -window.close() diff --git a/DemoPrograms/Demo_Justification_Using_Stretch_Elements.py b/DemoPrograms/Demo_Justification_Using_Stretch_Elements.py new file mode 100644 index 00000000..1acab1c9 --- /dev/null +++ b/DemoPrograms/Demo_Justification_Using_Stretch_Elements.py @@ -0,0 +1,36 @@ +import PySimpleGUI as sg + +""" + Demo Element Justification In A Window Using Stretch Elements + + How to Justify elements on 1 row to be left, right or left, middle, right + + Additionally, locate these buttons at the bottom of the screen + + + To get 2 buttons to be all the way to the left and to the far right, then + you want to place a Stretch element between them that expands + If you want a third button that is centered, then add TWO Stretch elements, one + on each side of the middle one + + Copyright 2021 PySimpleGUI +""" + + +layout = [ [sg.Text('Window with elements on the left and the right')], + [sg.T('Using a Stretch element that expands enables you to "push" other elements around')], + [sg.HorizontalSeparator()], + [sg.VStretch()], # Stretch verticaly + [sg.Button('Left'), sg.Stretch(), sg.Button('Right')], + [sg.Stretch(), sg.B('Right')], + [sg.Button('Left'), sg.Stretch(), sg.B('Middle'), sg.Stretch(), sg.Button('Right')] ] + +window = sg.Window('Left and Right Justification', layout, resizable=True) + +while True: + event, values = window.read() + print(event, values) + if event == sg.WIN_CLOSED or event == 'Exit': + break + +window.close()