python UI class and control commands

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 06 June 2013   #16
Hrm, I guess something like this:

In UI class:

      def addBtn(self, *args):
          self.newBtn = cmds.button(label = args[0])  
          return self.newBtn

Outside Class:

import maya.cmds as mc

myUI = NewUI('myWin')

myNewButton = myUI.addBtn('newBtn')

mc.button(myNewButton, e=1, c='print "new button clicked!"')
Old 06 June 2013   #17
Thanks Jack,

Thats a very clear example. I was wondering this scenario:

I have:

I want to build a button for each fluidShape that later might be added or deleted.

What is the best way to assign the button name to be called later and or to be recognized when the fluidShape is selected?

so myNewButton example above will be something dynamically named with eg: fluid1_button. How can I assign variable on the fly?

Thanks for your time


Old 06 June 2013   #18
You could use a list.

import maya.cmds as mc

myNewButtons = []

myUI = NewUI('myWin')


#later on

mc.button(myNewButtons[myNewButtons.index('fluidShape1')], e=1, c='print "fluidShape1 button clicked!"') 
Old 06 June 2013   #19
f.u.c.k.i.n.g ACE. Im gonna try this. Thanks a lot again for your time. I really appreciated it.

Old 06 June 2013   #20
np, glad to help
Old 06 June 2013   #21
Edit: MisPost.


Last edited by ldunham1 : 06 June 2013 at 10:57 PM. Reason: mis-Post
Old 06 June 2013   #22
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:03 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.