chriskiehl / Gooey

Turn (almost) any Python command line program into a full GUI application with one line
MIT License
20.66k stars 1.02k forks source link

Using add_argument_group inside add_argument_group do not look at the 'columns': 1 option #784

Open Shadoward opened 2 years ago

Shadoward commented 2 years ago

Hello,

I am try group create subgroup in a group but the gooey_options={'columns': 1} do not work in the parent one. The subgroups are all align in columns and not in row.

from gooey import Gooey, GooeyParser, options

@Gooey(tabbed_groups=True, navigation='SIDEBAR')
def main():
    parser = GooeyParser()
    sub = parser.add_subparsers(dest='ssss')

    # Main TABs
    parser = sub.add_parser('options',
                                        prog="Options")

    parent = parser.add_argument_group('Search Options', gooey_options={
        'columns': 1
    })
    parent.add_argument('--query-string', help='the search string')

    child_one = parent.add_argument_group('flags', gooey_options={'show_border': True, 'columns': 2})
    child_one.add_argument('--option1', help='some text here')
    child_one.add_argument('--option3', help='some text here3', pi'full_width': True})
    child_one.add_argument('--option34', help='some text here3', gooey_options={'full_width': True})
    child_one.add_argument('--option224', help='some text here3', gooey_options={'full_width': True})
    child_one.add_argument('--option24', help='some text here3', gooey_options={'full_width': True})

    child_two = parent.add_argument_group('price', gooey_options={'show_border': True})
    child_two.add_argument('--option2333', help='some text here')

    child_3 = parent.add_argument_group('price', gooey_options={'show_border': True})
    child_3.add_argument('--option333345', help='some text here')

    child_4 = parent.add_argument_group('price', gooey_options={'show_border': True})
    child_4.add_argument('--option333ssss345', help='some text here')

    parent2 = parser.add_argument_group('Search Options2', gooey_options={
        'columns': 3
    })
    parent2.add_argument('--query-string2', help='the search string')

    args = parser.parse_args()

if __name__ == '__main__':
    main()

image

Thanks! ^_^

Shadoward commented 2 years ago

@chriskiehl , ok I found a solution for the problem. (not sure is bullet proof yet) https://github.com/chriskiehl/Gooey/blob/329b6954befcb74f0243e1282e77ab7bff8e7abf/gooey/gui/components/config.py#L150

Replacing with hs = wx.BoxSizer(wx.VERTICAL).

image

Shadoward commented 2 years ago

Ok, not bullet proof, there is a big blank between the Group when using columns': 1 on the parent...try to find how to remove that blank..

Shadoward commented 2 years ago

I found a solution but the column option is not working on the parent group. Do not know if this is suitable for a pull request....

        hs = wx.BoxSizer(wx.VERTICAL)
        for e, subgroup in enumerate(group['groups']):
            self.makeGroup(parent, hs, subgroup, 1, wx.EXPAND)
            if len(group['groups']) != e:
                hs.AddSpacer(5)
            boxSizer.Add(hs, *args)
            hs = wx.BoxSizer(wx.VERTICAL)
            # # self.makeGroup(parent, hs, subgroup, 1, wx.ALL | wx.EXPAND, 5)
            # itemsPerColumn = getin(group, ['options', 'columns'], 2)
            # if e % itemsPerColumn or (e + 1) == len(group['groups']):
            #     boxSizer.Add(hs, *args)
            #     hs = wx.BoxSizer(wx.VERTICAL)