spyoungtech / spyoungtech/FreeSimpleGUI

[Feature request] Grid / Table layout helper or function

Open
#99 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
867
Forks
106
Avg merge
1m
Merged PRs (30d)
2

Description

I'd love something like sg.GridLayout(layout) or sg.TableLayout(layout) analogous to sg.Column(layout). An easy way to arrange elements in a grid.

This is already sort of the default when creating a layout as a nested list of rows where members are placed horizontally in each row, however currently there is no common delineation between those points in the default layout. This should definitely stay that way as it's a sensible way to handle things. Often though we might want elements to stack neatly on top of each with the same dimensions for a clean and readable layout.

This is the default look when layouting with the nested list:
Image

This is the resulting look when wrapping the elements in a grid layout helper:
Image

I'd love to discuss the possibilities for this. I've written a small helper function that can achieve this by itself, but any integration into the codebase will necessarily have to look different. If it would be useful to have though, I'll include that helper here:

def GridLayout(layout):
    column_layout = []
    columns_num = len(max(layout, key=len))
    for i in range(columns_num):
        column_list = []
        for row_list in layout:
            if i < len(row_list):
                value = row_list[i]
                if value == None: # This allows empty cells.
                    column_list.append([sg.Text("")])
                else:
                    column_list.append([value])
            else:
                column_list.append([sg.Text("")])
        column_layout.append(sg.Column(column_list))
    return column_layout

Using None is the option I went with to allow leaving cells in the grid structure empty. As I'm pretty new with FreeSimpleGUI, I made empty cells happen with empty text elements, but a proper integration could surely do better.

I've been very pleased with FreeSimpleGUI so far, so if there's interest in this and I could get some guidance on how to best integrate something like this, I'd be happy to give it a shot myself when I find time. Any thoughts would be appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing nested-list layout behavior and the sg.Column API described in the issue, then compare them with the supplied GridLayout helper. Define how empty cells and consistent dimensions should work, and confirm that the proposed integration has clear tests or examples showing the resulting grid layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.