Skip to content

launchforhiero

find_scripts_menu(title, parent)

Check if the menu exists with the given title in the parent

Parameters:

Name Type Description Default
title str

the title name of the scripts menu

required
parent QMenuBar

the menubar to check

required

Returns:

Type Description

QtWidgets.QMenu or None

Source code in client/ayon_hiero/api/launchforhiero.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def find_scripts_menu(title, parent):
    """
    Check if the menu exists with the given title in the parent

    Args:
        title (str): the title name of the scripts menu

        parent (QtWidgets.QMenuBar): the menubar to check

    Returns:
        QtWidgets.QMenu or None

    """

    menu = None
    search = [i for i in parent.children() if
              isinstance(i, scriptsmenu.ScriptsMenu)
              and i.title() == title]
    if search:
        assert len(search) < 2, ("Multiple instances of menu '{}' "
                                 "in menu bar".format(title))
        menu = search[0]

    return menu

main(title='Scripts', parent=None, objectName=None)

Build the main scripts menu in Hiero

Parameters:

Name Type Description Default
title str

name of the menu in the application

'Scripts'
parent QtMenuBar

the parent object for the menu

None
objectName str

custom objectName for scripts menu

None

Returns:

Type Description

scriptsmenu.ScriptsMenu instance

Source code in client/ayon_hiero/api/launchforhiero.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def main(title="Scripts", parent=None, objectName=None):
    """Build the main scripts menu in Hiero

    Args:
        title (str): name of the menu in the application

        parent (QtWidgets.QtMenuBar): the parent object for the menu

        objectName (str): custom objectName for scripts menu

    Returns:
        scriptsmenu.ScriptsMenu instance

    """
    hieromainbar = parent or _hiero_main_menubar()
    try:
        # check menu already exists
        menu = find_scripts_menu(title, hieromainbar)
        if not menu:
            log.info("Attempting to build menu ...")
            object_name = objectName or title.lower()
            menu = scriptsmenu.ScriptsMenu(title=title,
                                           parent=hieromainbar,
                                           objectName=object_name)
    except Exception as e:
        log.error(e)
        return

    return menu