User defined colors in UI

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 04 April 2013   #1
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 April 2013   #2
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 April 2013   #3
Turns out, you can do it with the native UI elements:



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 April 2013 at 05:20 PM. Reason: I think I missed the point.
 
Old 04 April 2013   #4
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 April 2013   #5
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 April 2013   #6
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 April 2013   #7
Alright. It is kinda ugly (need to get the spacings right), but what about:

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 April 2013 at 05:57 PM. Reason: Cleaner code.
 
Old 04 April 2013   #8
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 April 2013   #9
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 08:01 AM.


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