[Python] Dynamic Menu in Python

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    In my software I use a menu. As some items have to have the status normal / disabled depending of the state of the program I had the idea of creating a dynamic menu. The items I need are all in a database table (and the conditions). So far so good - I managed to create the menue / submenu. But I am failing to execute stuff from the various items:

    menu_0.add_command(label=menu_sub, command=menu_command, state="disabled")

    print(f"menu_command: {menu_command}")


    prints the various tests I made:

    Menu command: report_rules_not_used_some_time_v6(True, True)
    Menu command: gui_start_wizard()
    Menu command: lambda: gui_start_wizard()


    The called routine is available and works.

    The problem is that the menu_command never gets executed if I click the menu item.

    If I add it that way (no placeholder), it works:

    menu_0.add_command(
    label=menu_sub,
    command=lambda: gui_start_wizard(),
    state="normal"
    )


    I already consulted AI with no success... Any idea? Thx Martin

    Continue reading...

Compartilhe esta Página