CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 04-14-2013, 03:37 PM   #1
doffer
Keying everything
 
doffer's Avatar
portfolio
Christoffer Andersen
Animator
Valence, France
 
Join Date: Dec 2005
Posts: 929
User defined colors in UI

Is it possible to use the user-defined colors in the ui elements, like for instance color a button or something like the color-slider?
I could of course copy the rgb values into the rgb of the button, but I would like the connection to remain dynamic.

Basically I am looking for a way to have the user choose between the user colors within my own UI.
Any ideas?
__________________
Website
Steam Punk Challenge
 
Old 04-14-2013, 04:57 PM   #2
mikeboers
Frequenter
 
mikeboers's Avatar
portfolio
Mike Boers
Pipeline TD
Western Post
Canada
 
Join Date: Oct 2002
Posts: 102
I don't know about colouring the Maya UI elements natively off the top of my head, but...

Are you stuck with using the Maya provided UI elements, or can you inject a little Qt in there and force what you want?
 
Old 04-14-2013, 05:17 PM   #3
mikeboers
Frequenter
 
mikeboers's Avatar
portfolio
Mike Boers
Pipeline TD
Western Post
Canada
 
Join Date: Oct 2002
Posts: 102
Turns out, you can do it with the native UI elements:



Code:
import maya.cmds as cmds import random cmds.window(width=150) cmds.columnLayout(adjustableColumn=True) for _ in xrange(10): colour = [random.random() for _ in xrange(3)] cmds.button(label=', '.join('%.3f' % x for x in colour), backgroundColor=colour) cmds.showWindow()


See http://download.autodesk.com/global...backgroundColor

---

EDIT: I think I missed the point of the question; could you elaborate?

Last edited by mikeboers : 04-14-2013 at 05:20 PM. Reason: I think I missed the point.
 
Old 04-14-2013, 05:26 PM   #4
doffer
Keying everything
 
doffer's Avatar
portfolio
Christoffer Andersen
Animator
Valence, France
 
Join Date: Dec 2005
Posts: 929
Thanks a lot for your answer.

The colors I am talking about, are the ones from settings/preferences --> colors --> user defined.
It is the colors maya color the skinned joints for instance.

I want to use them as a color override, instead of the overrideColor thing.
It is a list 1-8.

It would just be nice to create a sweet little ui where I can choose the color I want, instead of going by the numbers 1-8.
__________________
Website
Steam Punk Challenge
 
Old 04-14-2013, 05:32 PM   #5
mikeboers
Frequenter
 
mikeboers's Avatar
portfolio
Mike Boers
Pipeline TD
Western Post
Canada
 
Join Date: Oct 2002
Posts: 102
Quote:
Originally Posted by doffer
It would just be nice to create a sweet little ui where I can choose the color I want, instead of going by the numbers 1-8.


I'm still a little confused here.

You want to a UI element for the user to pick from the 8 user defined colours, that at least displays the colour instead of just being a number?
 
Old 04-14-2013, 05:38 PM   #6
doffer
Keying everything
 
doffer's Avatar
portfolio
Christoffer Andersen
Animator
Valence, France
 
Join Date: Dec 2005
Posts: 929
exactly...
and then through a button, color a selected object with that color or something like that.
But it is displaying those colors in the UI i'm not sure of how to do.
Except copying the rgb value.

An alternative would be to make a optionMenu and use descriptive text instead, have that run from 0-7 and plus it with 1 ( to get the list from 1-8), but the most intuitive would be to have the actual color displayed somehow.
__________________
Website
Steam Punk Challenge
 
Old 04-14-2013, 05:51 PM   #7
mikeboers
Frequenter
 
mikeboers's Avatar
portfolio
Mike Boers
Pipeline TD
Western Post
Canada
 
Join Date: Oct 2002
Posts: 102
Alright. It is kinda ugly (need to get the spacings right), but what about:

Code:
from maya import cmds cmds.window() cmds.rowLayout(numberOfColumns=3) cmds.text(label='User Colour:') canvas = cmds.canvas(width=100, height=16) field = cmds.intSlider(minValue=1, maxValue=8, value=1) def update_canvas(index=1): colour = cmds.displayRGBColor('userDefined%d' % index, query=True) cmds.canvas(canvas, edit=True, rgbValue=colour) cmds.intSlider(field, edit=True, dragCommand=update_canvas) update_canvas() cmds.showWindow()



Last edited by mikeboers : 04-14-2013 at 05:57 PM. Reason: Cleaner code.
 
Old 04-14-2013, 06:00 PM   #8
doffer
Keying everything
 
doffer's Avatar
portfolio
Christoffer Andersen
Animator
Valence, France
 
Join Date: Dec 2005
Posts: 929
Fantastic!
That was exactly what I was after.
A bunch of stuff in your code I didn't know about.
I'll try and break it down to see what happens.

Thanks a lot for your help!
__________________
Website
Steam Punk Challenge
 
Old 04-14-2013, 06:00 PM   #9
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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 10:52 PM.


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