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 CLOSED
 
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!"')
__________________

gibby3d.com
 
Old 06 June 2013   #17
Thanks Jack,

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

I have:
|fluidShape1
|fluidShape2
|fluidShape3
|fluidShape4
group2|fluidShape1

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

F
__________________

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



import maya.cmds as mc

myNewButtons = []

myUI = NewUI('myWin')

myNewButtons.append(myUI.addBtn('newBtn'))

#later on

mc.button(myNewButtons[myNewButtons.index('fluidShape1')], e=1, c='print "fluidShape1 button clicked!"') 
__________________

gibby3d.com
 
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
__________________

gibby3d.com
 
Old 06 June 2013   #21
Edit: MisPost.

Apologies.
__________________
ldunham.blogspot.com

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 03:02 AM.


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