我正在尝试在对话框的state
中添加参数__init__
,如下所示:
class dialog_test(QtGui.QDialog):
def __init__(self, state, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle('Dialog Testing')
self.setModal(False)
self.state = state
if self.state == "stack":
# Run the function if the state is stack
if self.state == "user":
# Run the function if the state is user
...
def open_dialog():
current_selection = cmds.ls(sl=True)
if len(current_selection) == 1 and cmds.nodeType(current_selection) == 'stack':
check_for_nodes = main_code.get_nodes_in_scene()
state = "stack"
elif len(current_selection) > 1:
for items in current_selection:
if not 'Stack' in cmds.nodeType(items):
state = "user"
else:
cmds.warning("Please reselect")
return
dialog = dialog_test(state)
dialog.show()
return dialog
首先,这是正确的方法,对我来说感觉非常hacky并且它会有任何问题吗?
我问,因为我仍然在代码的后半部分使用state