Hi this is probably a very newbie question here but I'm trying to learn
creating a UI but it seems that the button will scale accordingly when i try to
rescale the window. How would I keep the button at a fixed size? It looks like
I missed a flag or something when i did this.
Also, what would be the ideal way to keep t he textfields and button center in
the middle of the window? Attached is the code.
import maya.cmds as cmds
class myUI:
def __init__(self):
self.name = "charname"
self.title = "UIBuilder"
# Begin creating the UI
if (cmds.window(self.name, q=1, exists=1)): cmds.deleteUI(self.name)
self.window = cmds.window(self.name, title=self.title, mxb=False,
mnb=False)
self.form = cmds.formLayout()
self.prefix = cmds.textFieldGrp(label='Prefix: ',text='')
cmds.separator(w=20)
self.charname = cmds.textFieldGrp(label='Name: ', text='')
cmds.separator(w=20)
self.rename = cmds.button(label='Create', w=50,rs=True, c=self.rename)
# Attach elements to form
cmds.formLayout( self.form,
edit=True, nd=3,
attachForm=[
(self.prefix, 'top', 20),
(self.prefix, 'left', 20),
(self.prefix, 'right', 20),
(self.charname, 'top', 20),
(self.charname, 'left', 20),
(self.charname, 'right', 20),
(self.rename, 'left', 20),
(self.rename, 'right',20)
],
attachControl=[
(self.charname, 'top', 2, self.prefix),
(self.rename, 'top', 2, self.charname)
]
)
cmds.separator(h=20)
cmds.window(self.window, e=1, w=400, h=103)
cmds.showWindow(self.window)
def rename(self, *args):
prefix = cmds.textFieldGrp(self.prefix, q=True, tx=True)
charname = cmds.textFieldGrp(self.charname, q=True, tx=True)
self.uiName = prefix + charname
print "Character name is: " + self.uiName
myUI()
Thank you
Bay Gann Boon
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].