Push element is a pseudo-element (also known as "User Defined Element"). It is in this category of elements due to how it is implemented. It is not a class or a subclass but rather a function that returns an element. Perhaps a "Pseudo-element" is a better term.
Push causes elements on the same row with it to move in a horizontal direction, away from the
Push element. It "pushes" elements away from it.
To right justify an element, place a
Push to the left of the elements to right justify. To center elements, place a
Push on the left and right sides. Your window needs to be wide enough to make the change noticeable. In this example, the
Input element is determining the width of the window and is wide enough to make the result of the
No event will be generated by the
No values dictionary entry will be present
Stretch in PySimpleGUIQt
Qt has a
Stretch widget which is where the idea for this element originated. It's unlikely that the implementation in the tkinter port of this element exactly matches how Qt's Stretch Widget works. It was more of an inspirational "hey, that's a cool idea..." than a "need to research & duplicate the functionality of Qt".
Push is Simplest & Easiest Way to Justify Elements
There are often more than 1 way to achieve the same results in a PySimpleGUI Window. Justifying elements within your window can be achieved using a
Column element by setting the
element_justification parameter. A
Column element along with the
justification parameter will also aid in justifying elements in a layout.
However, adding a
Push element (or two) to a row will require a lot less code than embedding the elements in a
If your window changes size, then the
Push element will expand/contract as the window changes size.