コンストレインを楽にしたい奴

bothconst.py
両手で一つの物を持たせるツール

参考にしたキータの記事、出版物等、色々ありますが、お世話になったサイト、ブログのURLをたくさん添付させて頂きます。
末尾に

```
from maya import OpenMayaUI
from PySide2 import QtWidgets, QtCore
import shiboken2 as shiboken
import maya.cmds as cmds

ptr = OpenMayaUI.MQtUtil.mainWindow()
parent = shiboken.wrapInstance(int(ptr), QtWidgets.QMainWindow)

class LocatorGUI(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super(LocatorGUI, self).__init__(parent)

        self.setWindowTitle("Locator Tool")
        self.resize(300, 200)

        self.central_widget = QtWidgets.QWidget()
        self.setCentralWidget(self.central_widget)

        self.main_layout = QtWidgets.QVBoxLayout(self.central_widget)

        # Step1 GroupBox
        self.step1_group = QtWidgets.QGroupBox("Step1")
        self.step1_layout = QtWidgets.QVBoxLayout(self.step1_group)
        self.select_object_button = QtWidgets.QPushButton("Select Object")
        self.select_object_button.clicked.connect(self.select_object)
        self.confirm_button = QtWidgets.QPushButton("Confirm")
        self.confirm_button.setEnabled(False)
        self.confirm_button.clicked.connect(self.confirm_object)

        self.step1_layout.addWidget(QtWidgets.QLabel("Select an object for tracking:"))
        self.step1_layout.addWidget(self.select_object_button)
        self.step1_layout.addWidget(self.confirm_button)

        self.step1_group.setLayout(self.step1_layout)

        # Step2 GroupBox
        self.step2_group = QtWidgets.QGroupBox("Step2")
        self.step2_layout = QtWidgets.QVBoxLayout(self.step2_group)
        self.strong_button = QtWidgets.QPushButton("Strong")
        self.strong_button.setEnabled(False)
        self.strong_button.clicked.connect(self.strong_object)
        self.weak_button = QtWidgets.QPushButton("Weak")
        self.weak_button.setEnabled(False)
        self.weak_button.clicked.connect(self.weak_object)

        self.step2_layout.addWidget(self.strong_button)
        self.step2_layout.addWidget(self.weak_button)

        self.step2_group.setLayout(self.step2_layout)

        self.main_layout.addWidget(self.step1_group)
        self.main_layout.addWidget(self.step2_group)
        self.setStyleSheet(
            '''
            QGroupBox {
                border: 2px solid #025c0d;
                border-radius: 6px;
                margin-top: 2em;
                font-size: 12px;
            }

            QGroupBox::title {
                color: #fff;
                background-color: #025c0d;
                subcontrol-origin: margin;
                padding: 0.5em 0.7em;
                border-top-left-radius: 6px;
                border-top-right-radius: 6px;
            }
            '''
        )


    def select_object(self):
        selected_objects = cmds.ls(selection=True, dag=True)
        if not selected_objects:
            cmds.warning("Please select an object.")
            return
        self.selected_object = selected_objects[0]
        self.confirm_button.setEnabled(True)
        self.strong_button.setEnabled(True)
        self.weak_button.setEnabled(True)

    def confirm_object(self):
        try:
            selected_object = self.selected_object
        except AttributeError:
            cmds.warning("Please select an object.")
            return

        group = cmds.group(selected_object, name=selected_object + "_group")
        bbox = cmds.exactWorldBoundingBox(selected_object)
        bbox_center = [(bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, (bbox[2] + bbox[5]) / 2]

        strong_locator = cmds.spaceLocator(name=selected_object + "_strong")[0]
        cmds.parent(strong_locator, selected_object)
        cmds.move(bbox_center[0], bbox_center[1], bbox_center[2], strong_locator)

        weak_locator = cmds.spaceLocator(name=selected_object + "_weak")[0]
        cmds.parent(weak_locator, strong_locator)
        cmds.xform(weak_locator, translation=bbox_center, worldSpace=True)

        cmds.button(label="OK", command=lambda x: cmds.deleteUI("locatorWindow", window=True))

    def strong_object(self):
        selected_strong_locator = cmds.ls(selection=True, type="transform")
        if not selected_strong_locator:
            cmds.warning("Please select the strong locator.")
            return
        selected_strong_locator = selected_strong_locator[0]

        try:
            selected_object = self.selected_object
        except AttributeError:
            cmds.warning("Please select an object.")
            return

        cmds.parentConstraint(selected_object, selected_strong_locator, mo=False)  # Changed mo to False

    def weak_object(self):
        selected_weak_locator = cmds.ls(selection=True, type="transform")
        if not selected_weak_locator:
            cmds.warning("Please select the weak locator.")
            return
        selected_weak_locator = selected_weak_locator[0]

        try:
            selected_object = self.selected_object
        except AttributeError:
            cmds.warning("Please select an object.")
            return

        cmds.parentConstraint(selected_object, selected_weak_locator, mo=False)  # Changed mo to False

def main():
    locator_gui = LocatorGUI(parent)
    locator_gui.show()

main()
```
__________________________________


スタイルシートでUIの見た目を良くしたい！

https://unpyside.com/blog/2023/01/27/qgroupbox-qss-01/