Skip to content

Reference

locatorcreator package.

create_locator(name='')

Create a locator with the given name.

Parameters:

Name Type Description Default
name str

The name to give the locator.

''

Returns:

Name Type Description
str str

The name of the locator that was created.

Source code in src/locatorcreator/example.py
 6
 7
 8
 9
10
11
12
13
14
15
def create_locator(name: str = "") -> str:
    """Create a locator with the given name.

    Args:
        name (str): The name to give the locator.

    Returns:
        str: The name of the locator that was created.
    """
    return cmds.spaceLocator(name=name)[0]

locatorcreator UI.

LocatorCreatorWindow

Bases: QDialog

A single-button window that creates a locator on click.

Source code in src/locatorcreator/ui.py
19
20
21
22
23
24
25
26
27
28
29
30
class LocatorCreatorWindow(QtWidgets.QDialog):
    """A single-button window that creates a locator on click."""

    def __init__(self, parent=None):
        super().__init__(parent or maya_main_window())
        self.setWindowTitle("Locator Creator")

        create_button = QtWidgets.QPushButton("Create Locator")
        create_button.clicked.connect(lambda: create_locator())

        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(create_button)

maya_main_window()

Return Maya's main window as a QWidget.

Returns:

Type Description

QtWidgets.QWidget: Maya's main window.

Source code in src/locatorcreator/ui.py
 9
10
11
12
13
14
15
16
def maya_main_window():
    """Return Maya's main window as a QWidget.

    Returns:
        QtWidgets.QWidget: Maya's main window.
    """
    main_window_ptr = omui.MQtUtil.mainWindow()
    return QtCompat.wrapInstance(int(main_window_ptr), QtWidgets.QWidget)

show()

Create and show the Locator Creator window.

Returns:

Name Type Description
LocatorCreatorWindow

The window that was shown.

Source code in src/locatorcreator/ui.py
33
34
35
36
37
38
39
40
41
def show():
    """Create and show the Locator Creator window.

    Returns:
        LocatorCreatorWindow: The window that was shown.
    """
    window = LocatorCreatorWindow()
    window.show()
    return window