I am building a simple GUI with pysimplegui
and want to right-justify a button inside a frame. I have found details on how to do this with text but not with buttons.
For example, I would like the button below to snap to the right side of the frame with the groove around it. I want this:
To look more like this:
But without having to add in a manually adjusted blank text element to get it close as this often doesn't line up correctly (note the commented out sg.Text("", size=(22, 1))
line below).
import sys
import PySimpleGUI as sg
sg.theme("Light Blue 2")
layout = [
[
sg.Text("Target folder", size=(9, 1)),
sg.InputText(default_text="Choose a folder...", size=(59, 1)),
sg.FolderBrowse(),
],
[
sg.Frame(
layout=[
[
sg.Text("First parameter", size=(15, 1)),
sg.InputText(default_text="2", size=(3, 1),),
],
[
sg.Text("Second parameter", size=(15, 1)),
sg.InputText(default_text="8", size=(3, 1),),
# sg.Text("", size=(22, 1)),
sg.Submit("A nice button", size=(23, 1)),
],
[sg.ProgressBar(1, orientation="h", size=(50, 20))],
],
title="Cool subpanel",
relief=sg.RELIEF_GROOVE,
)
],
]
window = sg.Window("Test window", layout)
while True:
event, values = window.read()
if event == "Cancel" or event is None:
sys.exit()