Hi there
I'm learning a little bit about UI. One problem I'm facing is that when I query sliders they are returning a fixed value of what was specified in the value flag during the creation of the slider group. No matter what I change the value of the slider to it always returns the same float of 1.0 when the window is open.
import maya.cmds as cmds
loadedLights = cmds.ls(lights=True)
def openLMWindow():
if cmds.window("LMW",exists=True):
cmds.deleteUI("LMW")
lmWindow = cmds.window("LMW",title="Light Manager",width=300, height=200,sizeable=False)
cmds.columnLayout(adjustableColumn=True)
LMWIconpath = cmds.internalVar(userPrefDir=True)+"icons/testLightManCon.png"
cmds.image(width=300,height=35,image=LMWIconpath)
cmds.separator(height=20,style="double")
#This is where the problem code is!#
gainSlider = cmds.floatSliderGrp(label="Gain Amount",field=True,value=1)
gain = cmds.floatSliderGrp(gainSlider,query=True,value=True)
###########
gainBtn = cmds.button(width=5,label="Change Intensity",command="gainLights(gain)")
amountBtn = cmds.button(width=5,label="Is it doing anything?",command="printAmount()")
closeBtn = cmds.button(width=5,label="Close",command="closeLMWindow()")
cmds.separator(width=25,style="double")
cmds.showWindow(lmWindow)
def printAmount():
print gain
def gainLights(gain):
lights = loadedLights
for light in lights:
cmds.select(light, replace=True)
intens = cmds.getAttr(".intensity")
newIntens = intens * gain
cmds.setAttr(".intensity",newIntens)
print light, "Olde:", intens,"Newe:", newIntens
def closeLMWindow():
cmds.deleteUI("LMW")
openLMWindow()
Any Help on the topic would be greatly apprecieated.
Kev
