【Maya:Python】グループノードだけ選択から除外する
shamimatsu
三味松ブログ
Adobe公式にサブスタンス3Dデザイナーのpythonでウィンドウを作成するコードがありましたが、ボタンが一つあるだけで押しても何も反応しない内容だったので、自作の関数を入れることができる仕組みを追加してみました。
スクリプトを実行して表示されるウィンドウにボタンが2つあり、ボタンを押すとコンソールに文字列がプリントされます。
コード内の以下の関数内の書き換えれば別の処理を組み込むことができます。
def on_button1_clicked(self):
def on_button2_clicked(self):
1import sd
2import sys
3from PySide2.QtWidgets import *
4
5
6class MainWindow(QWidget):
7 def __init__(self):
8 super().__init__()
9 app = sd.getContext().getSDApplication()
10 uiMgr = app.getQtForPythonUIMgr()
11
12 mainWindow = uiMgr.getMainWindow()
13 dialog = QDialog(parent=mainWindow)
14 dialog.setWindowTitle("window sample")
15 dialog.resize(300, 200)
16
17 button1 = QPushButton("Button 1")
18 button2 = QPushButton("Button 2")
19
20 layout = QVBoxLayout()
21 layout.addWidget(button1)
22 layout.addWidget(button2)
23 button1.clicked.connect(self.on_button1_clicked)
24 button2.clicked.connect(self.on_button2_clicked)
25
26 dialog.setLayout(layout)
27
28 dialog.show()
29
30 def on_button1_clicked(self):
31 print("Button 1 clicked.")
32
33 def on_button2_clicked(self):
34 print("Button 2 clicked.")
35
36Window = MainWindow()
アドビ公式:Creating user interface elements
スポンサーリンク