Adding macros to non-standard menu

What is proper way to add macros to non-standard menu?

It's possible to create non-standard menu with app.main_window().menu().insert_menu() in autorun macro, but it looks like isn't not possible to specify that other macros that should be added to that menu, should be loaded after autorun macro (i. e. explicit dependencies between macros).

Comments

  • I found answer to my question: non-standard menu could be created in script executed with -rm command-lien argument.

  • Hi,

    you can create submenus while specifying the menu path using a special notation:

    edit_menu.submenu>end("Sub menu").end
    

    For details see https://www.klayout.de/doc-qt4/about/macro_in_menu.html

    I guess this solves the submenu problem without a pre-runner script.

    Matthias

  • Thank you for hints, Matthias!

    Problem is that I needed to create top-level menu and another problem that macro title contained special symbols ("(", "+", ",", ")") so their internal names were not obvious.

    Is there way to insert menu before particular item (for example, separator)? So macros could be grouped visually?

  • Hi,

    it's possible, but only by switching to a different way of configuring the system.

    If you supply a menu binding for a macro, this is just a convenient way to shortcut the definition of a menu item. In this case, the system provides the menu entries for you - but with some limitations as you experience.

    The basic and flexible way of doing menu construction is to stop assigning menu items in the macro's properties and building the menus using Action objects instead. Macros still reside in their own files (which then can be plain .py or .rb files then) and provide functions that will be called. Then, call these functions in the trigger event of the respective Actions. This is similar to what you did in the autorun macro, but extended to building the full menu tree.

    Matthias

  • Hi, Matthias!

    Thank you for suggestion! Sure, Actions are much more flexible way to construct menus.

Sign In or Register to comment.