Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subparser sections not switching due to a wxPython problem? #872

Open
4 tasks done
twardoch opened this issue Apr 5, 2023 · 0 comments
Open
4 tasks done

Subparser sections not switching due to a wxPython problem? #872

twardoch opened this issue Apr 5, 2023 · 0 comments

Comments

@twardoch
Copy link

twardoch commented Apr 5, 2023

Hello There, Future Issue Creator!

  • OS: macOS Ventura 13.2.1 Intel
  • Python Version: 3.10.10 Intel
  • Gooey Version: from Git 2023-04-05
  • Thorough description of problem

In my code (full code is here) I have two subparsers:

@Gooey(
    advanced=True,
    group_by_type=True,
    navigation="Tabbed",
    optional_cols=2,
    required_cols=1,
    requires_shell=True,
    show_sidebar=True,
    sidebar_title="Actions",
    suppress_gooey_flag=True,
    tabbed_groups=True,
    use_legacy_titles=False,
    # (...)
def get_parser():
    common_parser = GooeyParser(add_help=False)
    common_parser.add_argument(
        "-i",
        "--image",
        required=True,
        type=Union[Path, str],
        dest="image",
        metavar="Input image",
        help="Path to the input image file",
        widget="FileChooser",
        gooey_options={
            **STD_OPTIONS,
            **{
                "wildcard": "PNG Images|*.png|JPG Images|*.jpg|JPEG Images|*.jpeg",
                "default_dir": str(get_pictures_folder()),
                "message": "Choose an image",
                "full_width": True,
            },
        },
    )
    common_settings_group = common_parser.add_argument_group("Preferences")
    common_settings_group.add_argument(
        "-O",
        "--openai-api-key",
        type=str,
        dest="openai_api_key",
        metavar="OpenAI API key",
        help="Not needed if OPENAI_API_KEY environment variable is set",
        gooey_options={
            **STD_OPTIONS,
            **{},
        },
    )
    # (...)

    parser = GooeyParser(
        prog="",
        description="Perform iterative inpainting on an image file using OpenAI's DALL-E 2 model.",
    )
    subparsers = parser.add_subparsers(dest="command", help="commands")

    inpaint_parser = subparsers.add_parser(
        "inpaint",
        help="Perform iterative inpainting on an image file",
        parents=[common_parser],
    )
    inpaint_parser.add_argument(
        "-o",
        "--output",
        type=Union[Path, str],
        dest="output",
        metavar="Output image",
        help="Path to the output image file",
        widget="FileSaver",
        gooey_options={
            **STD_OPTIONS,
            **{
                "wildcard": "PNG Images|*.png",
                "default_dir": str(get_pictures_folder()),
                "message": "Choose the image destination",
                "full_width": True,
            },
        },
    )
    # (...)
    describe_parser = subparsers.add_parser(
        "describe",
        help="Describe the image",
        parents=[common_parser],
    )

    return parser

When I run the tool, I get the default layout for the inpaint command:

scr- 2023-04-05 at 16 52 39

But when I choose the describe command, I also get the same content (and it shouldn't be so):

scr- 2023-04-05 at 16 52 44

In Terminal, I get:

Traceback (most recent call last):
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/gooey/gui/application/application.py", line 264, in handleSelectAction
    self.set_state(assoc(self.state, 'activeSelection', event.Selection))
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/rewx/core.py", line 273, in set_state
    patch(self.base, self.render())
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/rewx/core.py", line 102, in patch
    update(vdom, dom)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/rewx/dispatch.py", line 26, in wrapper
    return registry[element['type']](element, parent)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/rewx/widgets.py", line 110, in frame
    frame.taskbarIcon = wx.adv.TaskBarIcon(iconType=wx.adv.TBI_DOCK)
wx._core.wxAssertionError: C++ assertion "!sm_dockIcon" failed at /Users/robind/projects/bb2/dist-osx-py310/build/ext/wxWidgets/src/osx/cocoa/taskbar.mm(251) in wxTaskBarIconDockImpl(): You should never have more than one dock icon!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant