,但現階段似乎沒辦法透過 Qt Designer 來做一個 attrFieldSliderGrp,只好先用寫的,如下,
import pymel.core as pm ball = pm.sphere() win = pm.window(title="attrFieldSliderGrp test") pm.columnLayout() # create 3 attribute field slider group level_1_sliderGrp = pm.attrFieldSliderGrp(label="Level 1",min=0,max=85,attribute='%s.tx' % ball[0]) level_2_sliderGrp = pm.attrFieldSliderGrp(label="Level 2",min=0,max=85,attribute='%s.ty' % ball[0]) level_3_sliderGrp = pm.attrFieldSliderGrp(label="Level 3",min=0,max=85,attribute='%s.tz' % ball[0]) pm.showWindow(win)
三個 slider 分別控制球的 x, y, z 位置,range 從 0 ~ 85,
再加上一個 check box 來控制 visiblity
import pymel.core as pm def visOnCommand(theObject): ball[0].setAttr('visibility', True) def visOffCommand(theObject): ball[0].setAttr('visibility', False) ball = pm.sphere() win = pm.window(title="attrFieldSliderGrp test") pm.columnLayout() level_1_sliderGrp = pm.attrFieldSliderGrp(label="Level 1",min=0,max=85,attribute='%s.tx' % ball[0]) level_2_sliderGrp = pm.attrFieldSliderGrp(label="Level 2",min=0,max=85,attribute='%s.ty' % ball[0]) level_3_sliderGrp = pm.attrFieldSliderGrp(label="Level 3",min=0,max=85,attribute='%s.tz' % ball[0]) # create check box with init checked, on/off command vis_checkBox = pm.checkBox("visToggle", value=True, onCommand=visOnCommand, offCommand=visOffCommand) pm.showWindow(win)
UI 之路其實還很長,但在書中的第四章其實只是起個頭而已,了解基本的 UI 運作,對之後更進階的 UI 會發現也只是一堆基本元件的組合而已,如果不是太創新的東西,不過一句話,基礎愈扎實之後的路也才會愈好走。
No comments:
Post a Comment