1 回答

TA貢獻(xiàn)1841條經(jīng)驗 獲得超3個贊
老實說,我不知道答案,因為每當(dāng)我不得不深入研究 Maya 的原生 UI 內(nèi)容時,它都會讓我質(zhì)疑自己的生活。
所以我知道這不完全是你要的,但我會選擇這個:PySide改為使用。乍一看,它可能會讓您“哇,這太難了”,但它也好一百萬倍(實際上更容易)。它更強(qiáng)大,更靈活,有很好的文檔,并且還可以在 Maya 之外使用(因此對學(xué)習(xí)很有用)。Maya 自己的界面使用相同的框架,因此您甚至可以PySide在熟悉后使用它進(jìn)行編輯。
這是一個在窗口中創(chuàng)建居中按鈕的簡單示例:
# Import PySide libraries.
from PySide2 import QtCore
from PySide2 import QtWidgets
class MyWindow(QtWidgets.QWidget): # Create a class for our window, which inherits from `QWidget`
def __init__(self, parent=None): # The class's constructor.
super(MyWindow, self).__init__(parent) # Initialize its `QWidget` constructor method.
self.my_button = QtWidgets.QPushButton("My button!") # Create a button!
self.my_layout = QtWidgets.QVBoxLayout() # Create a vertical layout!
self.my_layout.setAlignment(QtCore.Qt.AlignCenter) # Center the horizontal alignment.
self.my_layout.addWidget(self.my_button) # Add the button to the layout.
self.setLayout(self.my_layout) # Make the window use this layout.
self.resize(300, 300) # Resize the window so it's not tiny.
my_window_instance = MyWindow() # Create an instance of our window class.
my_window_instance.show() # Show it!
還不錯,對吧?
添加回答
舉報