I need to generate a section of a form with 4 columns. Since the sg.Table element doesn't accept other elements as content, I'm not sure how to achieve a side by side layout. I've been using PySimpleGUI for awhile, and I really like it. Studying the docs and playing around with examples but this issue has me stumped. I tried nested sg.Col elements but couldn't get this effect.
The point of using a table is to keep the columns aligned when the checkbox label length varies. No heading is required, the first column is just a single multi-line sg.Text label for the checkboxes in the other columns. Ideally the first column should be vertically aligned center.
The list of checkboxes will be generated based on a json configuration file.
[] bitchute1 [] vimeo7 [] youtube13
Platforms: [] bitchute.2 [] vimeo8hhhhhhh [] youtube14 some size
[] bitchute...3 [] vimeo9jjj [] youtube15
(select all [] bitchute..4 [] vimeo10uiuyu [] youtube16 whatever
that apply) [] bitchute...5 [] vimeo11 [] youtube17
[] bitchute6khjhj [] vimeo12 [] youtube18
Of all the trials, I wasn't able to modify the example to keep variable length content aligned into columns like the example, which uses fixed width column data.
Just put 4 columns at the same row with different elements, like Text
and Checkbox
elements.
import PySimpleGUI as sg
checks = [
["bitchute", "bitchute.2", "bitchute...3", "bitchute..4", "bitchute...5", "bitchute6khjhj"],
["vimeo7", "vimeo8hhhhhhh", "vimeo9jjj", "vimeo10uiuyu", "vimeo11", "vimeo12"],
["youtube13", "youtube14 some size","youtube15", "youtube16 whatever", "youtube17", "youtube18"],
]
column = [
[[sg.Text('Platforms:\n\n(select all\nthat apply)')]]] + [
[[sg.Checkbox(text, pad=(5, 0), key=('Check', j, i))] for i, text in enumerate(check)] for j, check in enumerate(checks)
]
layout = [[sg.Column(column[i]) for i in range(4)]]
sg.Window('Title', layout).read(close=True)