qtテスト、デフォ書式
# -*- coding: utf-8 -*-
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)
# UIの書式設定
class LocatorGUI(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(LocatorGUI, self).__init__(parent)
self.setWindowTitle("both constrain")
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("オブシェクトを指定")
self.select_object_button.clicked.connect(self.select_object)
self.confirm_button = QtWidgets.QPushButton("確定")
self.confirm_button.setEnabled(False)
self.confirm_button.clicked.connect(self.confirm_object)
self.step1_layout.addWidget(QtWidgets.QLabel("一つのオブシェクトを指定し、確定を押下して下さい"))
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(QtWidgets.QLabel("Strong=利き手を指定してください"))
self.step2_layout.addWidget(self.strong_button)
self.step2_layout.addWidget(QtWidgets.QLabel("Weak=添える手を指定してください"))
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 #256d7b;
border-radius: 6px;
margin-top: 1em;
font-size: 12px;
}
QGroupBox::title {
color: #fff;
background-color: #256d7b;
subcontrol-origin: margin;
padding: 0.5em 0.7em;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}
QTabWidget::pane {
border: 1px solid #256d7b;
border-radius: 6px;
}
QTabWidget::tab-bar {
alignment: center;
}
QTabBar::tab {
background: #256d7b;
color: #fff;
padding: 5px 10px;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
margin-right: 1px;
}
QTabBar::tab:selected {
background: #1e555f;
}
'''
)
def main():
global rename_tool
try:
rename_tool.close() # 既存のウィンドウを閉じる
except:
pass
rename_tool = RenameTool(parent)
rename_tool.show()
main()
テンプレート