There is way to specify a "position" for a menu item and toolbars ?

Need help, or want to share a macro? Post here!
Post Reply
User avatar
onekk
Veteran
Posts: 2458
Joined: Sat Jan 17, 2015 7:48 am
Contact:

There is way to specify a "position" for a menu item and toolbars ?

Post by onekk »

Hello, as in the title, there is a way to specify the position of a menu item:

Using word, I want to place my menu after Macro (or maybe prior of Help).

For Toolbars, I want to place my toolbar prior of "Part tools" (this is the name of one of the Part WB toolbars).

In alternatives, there is some documentation or code to "study" to see how the things are placed.

I want to make this things, in Python.

Regards

Carlo D.
My English and Italian Scripting Guide https://github.com/onekk/freecad-doc.
My Blog: https://onekk-maker.blogspot.com/

To help development see on GitHub Page

For enquiry about customized FC Scripting job PM me.
User avatar
onekk
Veteran
Posts: 2458
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: There is way to specify a "position" for a menu item and toolbars ?

Post by onekk »

Nobody has some hint?

Regards

Carlo D.
My English and Italian Scripting Guide https://github.com/onekk/freecad-doc.
My Blog: https://onekk-maker.blogspot.com/

To help development see on GitHub Page

For enquiry about customized FC Scripting job PM me.
mario52
Veteran
Posts: 3933
Joined: Wed May 16, 2012 2:13 pm

Re: There is way to specify a "position" for a menu item and toolbars ?

Post by mario52 »

Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting. My macros on Gist.github here complete macros Wiki and forum.
User avatar
onekk
Veteran
Posts: 2458
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: There is way to specify a "position" for a menu item and toolbars ?

Post by onekk »

mario52 wrote: Sat May 28, 2022 9:32 am Hi

maybe study PersistentToolbars and Remember active workbench by tab

mario

Ok i have seen that the toolbar is:

Code: Select all

tb = mw.findChildren(QtGui.QToolBar)
But I haven't guessed how to put a new "item" after another item, I suspect that some "list" or similar thing manipulation must be done, but how?

My main problem is the "menu item" that is placed prior of "File" when the menu is activated.

I could scan the menu with:

Code: Select all

def scan_menubar():
    menu = mw.menuWidget()
    actions = menu.actions()
    a = actions
    
    
    num_act = len(a)
    
    b = []
    sep_pos = None
    
    for ii in range(0, len(a)):
        FreeCAD.Console.PrintMessage(f"n: {ii} text: {a[ii].text()}  Name: {a[ii].objectName()}\n")

        if a[ii].objectName() == "Separator":
            sep_pos = ii
        else:
            b.append(a[ii])

    print(f"Separator position: {sep_pos}")    

And I can guess that menu.actions() is thing to manipulate, but how to manipulate it seems the problem.

Any hints?

TIA and Regards

Carlo D.
My English and Italian Scripting Guide https://github.com/onekk/freecad-doc.
My Blog: https://onekk-maker.blogspot.com/

To help development see on GitHub Page

For enquiry about customized FC Scripting job PM me.
Post Reply