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
  06 June 2013
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!"')
  06 June 2013
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


  06 June 2013
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!"') 
  06 June 2013
f.u.c.k.i.n.g ACE. Im gonna try this. Thanks a lot again for your time. I really appreciated it.

  06 June 2013
np, glad to help
  06 June 2013
Edit: MisPost.


Last edited by ldunham1 : 06 June 2013 at 10:57 PM. Reason: mis-Post
  06 June 2013
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
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 04:10 PM.

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