Last active
August 26, 2016 04:41
-
-
Save oglops/cd8e44df95b24e90f7e6ff8316697a25 to your computer and use it in GitHub Desktop.
embed a image browser button into script editor with xml attribute editor template in maya 2015
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.utils as mutils | |
def AEaddImgBrowserModule( plug, uiLabel, annot): | |
cmds.rowLayout( nc=3 ) | |
cmds.text(l=uiLabel) | |
p=cmds.textField('imagePathField') | |
cmds.symbolButton('browser',i="navButtonBrowse.png" ) | |
def AEaddImgBrowserModuleCB( *args ): | |
from PyQt4.QtGui import QFileDialog | |
dlg = QFileDialog() | |
dlg.setFileMode(QFileDialog.AnyFile) | |
dlg.setFilter("jpg files (*.jpg)") | |
filename = None | |
if dlg.exec_(): | |
filename = dlg.selectedFiles() | |
print 'get file name:',filename,str(filename[0]) | |
if filename and len(filename): | |
file=str(filename[0]) | |
cmds.setAttr( plug, file,type='string') | |
cmds.textField(p,e=1,tx=file) | |
cmds.symbolButton('browser',e=1,c= AEaddImgBrowserModuleCB) | |
cmds.setParent(u=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<templates> | |
<template name="AEtransform"> | |
<attribute name="frameExtension" type="maya.long"> | |
<label>Frame Extension</label> | |
</attribute> | |
<attribute name="enumAttr" type="maya.enum"> | |
<label>Enum Attr</label> | |
</attribute> | |
<attribute name="imageName" type="maya.string"> | |
<label>Image Name</label> | |
<description language="cb">py.AEaddImgBrowser.AEaddImgBrowserModule</description> | |
</attribute> | |
</template> | |
<view name="Custom" template="AEtransform"> | |
<property name="frameExtension"/> | |
<property name="enumAttr"/> | |
<property name="imageName"/> | |
</view> | |
</templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment