我需要知道用户按下回车后如何正确关闭此窗口。
txtA = cmds.textField(w = 345, h = 28, text = item, ec = renFc, aie = True)
按下回车后调用此函数:def ren():
我尝试放入cmds.deleteUI(renUI)
refFc 函数,但这使它崩溃。
这是完整的代码:
import maya.cmds as cmds
'''
Rename popup box for outliner - copy/paste this script into a hotkey field in the hotkey editor
'''
class ReUI():
def __init__(self):
renUI = 'renUI'
if cmds.window(renUI, exists = True):
cmds.deleteUI(renUI)
renUI = cmds.window(renUI, t = 'JT Rename UI', sizeable = True, tb = True, mnb = False, mxb = False, menuBar = True, tlb = False, nm = 5)
form = cmds.formLayout()
rowA = cmds.rowColumnLayout(w = 350, h = 30)
item = cmds.ls(os = True)[0]
def ren():
def renFc(self):
print 'yes'
tval = cmds.textField(txtA, text = True, q = True)
cmds.rename(item, tval)
txtA = cmds.textField(w = 345, h = 28, text = item, ec = renFc, aie = True)
ren()
cmds.showWindow(renUI)
r = ReUI()