Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在玛雅:
我正在构建一个动态 UI,它为每个字符创建一个带有字符名称的按钮。为了简单起见,我想在单击按钮时打印按钮的名称。我无法让它工作,因为按钮是用一个 btn=cmds.button('%sBtn'%character,c="print btn") 行创建的。因此,当我单击按钮时,只会打印 for 循环中最后创建的按钮。有什么想法吗?
cmds.window( width=150 ) cmds.columnLayout( adjustableColumn=True ) for i in range(5): btnName = 'button'+str(i) btnCmd = ('print \'%s\'')%(btnName) cmds.button( btnName, label='Button 1', command=btnCmd ) cmds.showWindow()