Currently writing a simple script inside maya to fetch camera info and present it in a GUI. The script prints the camera data of the selected camera no problem however I can't seem to get it to update the text fields with the data when the button is hit. I'm sure its a simply callBack but i can't work out how to do it.
Heres the code:
from pymel.core import *
import pymel.core as pm
camFl = 0
camAv = 0
win = window(title="Camera Information", w=300, h=100)
layout = columnLayout()
txtFl = text("Field Of View:"),textField(ed=0,tx=camFl)
pm.separator( height=10, style='double' )
txtAv = text("F-Stop:"),textField(ed=0,tx=camAv)
pm.separator( height=10, style='double' )
btn = button(label="Fetch Data", parent=layout)
def fetchAttr(*args):
camSel = ls(sl=True)
camAttr = camSel[0]
cam = general.PyNode(camAttr)
camFl = cam.fl.get()
camAv = cam.fs.get()
print "Camera Focal Length: " + str(camFl)
print "Camera F-Stop: " + str(camAv)
btn.setCommand(fetchAttr)
win.show()
Thanks!