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

GTK unable to put a menu item after submenu #2418

Closed
RastislavKish opened this issue Feb 23, 2024 · 1 comment · Fixed by #2421
Closed

GTK unable to put a menu item after submenu #2418

RastislavKish opened this issue Feb 23, 2024 · 1 comment · Fixed by #2421
Labels
bug A crash or error in behavior. linux The issue relates Linux support.

Comments

@RastislavKish
Copy link

RastislavKish commented Feb 23, 2024

Describe the bug

I would like to achieve the following menu structure in a Greeter app:

Greeting {// The root group and menu
    - Style { //A subgroup and a submenu
        - Formal //Command
        - Informal //Command
    }
    - Greet //A command
}

However, when trying to do so, I end up with the following menu structure instead:

Greeting {// The root group and menu
    - Style { //A subgroup and a submenu
        - Formal //Command
        - Informal //Command
        - Greet //Command, shouldn't be here
    }
}

Steps to reproduce

  1. Run the example code below
  2. Click on the Greeting menu and see its structure, which is laid out as mentioned above

Expected behavior

With the proper configuration of parent groups and orders, the menu should be laid out like described in the goal structure.

Screenshots

No response

Environment

  • Operating System: Ubuntu Mate 22.04 64-bit
  • Python version: 3.10
  • Software versions:
    • Toga: 0.4.2

Logs


Additional context

Here is the example code (the commands are dummy):

import toga
from toga import App, Command, Group, MainWindow

class GreeterWindow(MainWindow):

    def __init__(self):
        super().__init__(None, "Greeter")

        greeting_group=Group("Greeting")
        style_group=Group("Style", parent=greeting_group, order=1)

        formal=Command(self.formal,
            text="Formal",
            group=style_group,
            order=1,
            )
        informal=Command(self.informal,
            text="Informal",
            group=style_group,
            order=2,
            )
        greet=Command(self.greet,
            text="Greet",
            group=greeting_group,
            order=2,
            )

        self.toolbar.add(formal, informal, greet)

    def formal(self, sender):
        pass
    def informal(self, sender):
        pass

    def greet(self, sender):
        pass

class GreeterApp(App):

    def __init__(self):
        super().__init__("greeter", "com.example.greeter")

    def startup(self):
        self.main_window=GreeterWindow()
        self.main_window.show()

GreeterApp().main_loop()

Thanks!

@RastislavKish RastislavKish added the bug A crash or error in behavior. label Feb 23, 2024
@freakboy3742 freakboy3742 added the linux The issue relates Linux support. label Feb 24, 2024
@freakboy3742
Copy link
Member

freakboy3742 commented Feb 24, 2024

Thanks for the report - I can confirm I can reproduce this. It appears to be GTK specific; macOS and Windows both render the menu correctly.

The problem appears to be that the lookup of menu sections isn't contextual; as a result, the greeter is being added to the currently active section (the submenu), rather than the main section of the top level "greeting" menu. I should have a fix for this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. linux The issue relates Linux support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants