Example #1
0
    def saveCopy(self, data):
        "Button callback to end the dialog"
        self.info('saveCopy')

        resName = self.currentResourceName()
        if resName is None:
            return

        ext = os.path.splitext(resName)[1]
        if ext == '':
            ext = '.png'

        # Bring a file browser to select where to save the copy
        captionStr = maya.stringTable['y_resourceBrowser.kPickIconCaption']
        iconDir = cmds.internalVar(userBitmapsDir=True)
        fileList = cmds.fileDialog2(caption=captionStr,
                                    fileMode=0,
                                    okCaption=captionStr,
                                    fileFilter='*' + ext,
                                    startingDirectory=iconDir)
        path = None
        if fileList is not None:
            if (len(fileList) > 0) and (fileList[0] <> ""):
                path = fileList[0]

        if path is not None:
            self.info("saveCopy: Path=" + path)
            cmds.resourceManager(saveAs=(resName, path))
Example #2
0
    def saveCopy(self, data):
        "Button callback to end the dialog"

        resName = self.currentResource
        if resName is None:
            return

        ext = os.path.splitext(resName)[1]
        if ext == '':
            ext = '.png'

        # Bring a file browser to select where to save the copy
        captionStr = stringTable['y_resourceBrowser.kPickIconCaption']
        iconDir = cmds.internalVar(userBitmapsDir=True)
        fileList = cmds.fileDialog2(caption=captionStr,
                                    fileMode=0,
                                    okCaption=captionStr,
                                    fileFilter='*' + ext,
                                    startingDirectory=iconDir)
        path = None
        if fileList is not None:
            if len(fileList) > 0 and fileList[0] != "":
                path = fileList[0]

        if path is not None:
            cmds.resourceManager(saveAs=(resName, path))
Example #3
0
    def __init__(self, parent=getMayaWindow()):
        super(Window, self).__init__(parent)
        self.setupUi(self)
        self.setStyleSheet(Window.StyleSheet)
        
        self.setWindowTitle('icon chooser %s by %s' % (__version__,u'大叔'))
        
        delimiter = ':'
        if platform.system() == 'Windows':
            delimiter = ';'
        self.iconPath = os.environ['XBMLANGPATH'].split(delimiter)
        
        if platform.system() == 'Linux':
            self.iconPath = [os.path.dirname(p) for p in self.iconPath if p.endswith('%B')]

        pathWithIcons=[]
        for p in self.iconPath:
            print p
            if os.path.isdir(p):
                files = os.listdir(p)
                if files:
                    pathWithIcons.append(p)

        self.allIcons = cmds.resourceManager(nameFilter="*.png")

        pathWithIcons.insert(0,'Internal Icons')
        self.comboBox.addItems(pathWithIcons)
        
        self.initialize()
        
        self.listView.clicked.connect(self.selectIcon)
        self.comboBox.currentIndexChanged.connect(self.initialize)
Example #4
0
    def __init__(self, parent=getMayaWindow()):
        super(Window, self).__init__(parent)
        self.setupUi(self)
        self.setStyleSheet(Window.StyleSheet)

        self.setWindowTitle('icon chooser %s by %s' % (__version__, u'大叔'))

        delimiter = ':'
        if platform.system() == 'Windows':
            delimiter = ';'
        self.iconPath = os.environ['XBMLANGPATH'].split(delimiter)

        if platform.system() == 'Linux':
            self.iconPath = [
                os.path.dirname(p) for p in self.iconPath if p.endswith('%B')
            ]

        pathWithIcons = []
        for p in self.iconPath:
            print p
            if os.path.isdir(p):
                files = os.listdir(p)
                if files:
                    pathWithIcons.append(p)

        self.allIcons = cmds.resourceManager(nameFilter="*.png")

        pathWithIcons.insert(0, 'Internal Icons')
        self.comboBox.addItems(pathWithIcons)

        self.initialize()

        self.listView.clicked.connect(self.selectIcon)
        self.comboBox.currentIndexChanged.connect(self.initialize)
Example #5
0
 def __init__(self):
     self.winName = "resourcesBrowser"
     self.verbose = False
     self.currentResource = None
     self.resources = cmds.resourceManager(nameFilter='*')
     self.numIconCol = 20
     self.numIconRow = 5
     self.numIcons = self.numIconCol * self.numIconRow
     self.symbolButtons = []
     self.iconsOffset = 0
Example #6
0
    def updateFilter(self, data):
        "Update the list based on the new filter"
        self.info('updateFilter')
        filterVal = cmds.textFieldGrp(self.wFilter, query=True, text=True)
        self.resList = cmds.resourceManager(nameFilter=filterVal + '*')
        if self.resList is None:
            self.resList = []

        # Populate the list with all icons from the resources
        cmds.textScrollList(self.wList, edit=True, removeAll=True)
        for name in self.resList:
            cmds.textScrollList(self.wList, edit=True, append=name)
        cmds.textScrollList(self.wList, edit=True, selectIndexedItem=1)
        self.updatePreview()
        cmds.setFocus(self.wList)
 def maya_icons(self):
     return cmds.resourceManager(nameFilter=self.search_filter)
Example #8
0
def run():

    fileMaskPattern = re.compile(r'^.*\.(?:(?:png)|(?:xpm))$', re.IGNORECASE)
    images = set()

    for path in [p.strip() for p in os.environ['XBMLANGPATH'].split(';')]:
        if not os.path.exists(path):
            continue
        dirContents = os.listdir(path)
        if not dirContents:
            continue

        for i in [
                f for f in dirContents if os.path.isfile(os.path.join(path, f))
        ]:
            if fileMaskPattern.match(i):
                images.add(i)

    allImages = sorted(
        [str(s) for s in set(m.resourceManager(nf='*.png')) | images],
        key=str.lower)

    if m.window(WINDOW_NAME, exists=True):
        m.deleteUI(WINDOW_NAME)

    m.window(WINDOW_NAME,
             t='{} maya icons'.format(len(allImages)),
             w=700,
             h=650)

    m.scrollLayout()

    m.rowColumnLayout(numberOfColumns=20,
                      columnWidth=[
                          (1, ICON_WIDTH),
                          (2, ICON_WIDTH),
                          (3, ICON_WIDTH),
                          (4, ICON_WIDTH),
                          (5, ICON_WIDTH),
                          (6, ICON_WIDTH),
                          (7, ICON_WIDTH),
                          (8, ICON_WIDTH),
                          (9, ICON_WIDTH),
                          (10, ICON_WIDTH),
                          (11, ICON_WIDTH),
                          (12, ICON_WIDTH),
                          (13, ICON_WIDTH),
                          (14, ICON_WIDTH),
                          (15, ICON_WIDTH),
                          (16, ICON_WIDTH),
                          (17, ICON_WIDTH),
                          (18, ICON_WIDTH),
                          (19, ICON_WIDTH),
                          (20, ICON_WIDTH),
                      ])

    for image in allImages:
        cmd = 'print("{}")'.format(image)
        try:
            m.symbolButton(image=image, ann=image, c=cmd, w=35, h=35)
        except StandardError:
            pass

    m.window(WINDOW_NAME, e=True, wh=[712, 656])
    m.showWindow(WINDOW_NAME)
Example #9
0
def run():

    fileMaskPattern = re.compile(r'^.*\.(?:(?:png)|(?:xpm))$', re.IGNORECASE)
    images = set()

    for path in [p.strip() for p in os.environ['XBMLANGPATH'].split(';')]:
        if not os.path.exists(path):
            continue
        dirContents = os.listdir(path)
        if not dirContents:
            continue

        for i in [f for f in dirContents if os.path.isfile(os.path.join(path, f))]:
            if fileMaskPattern.match(i):
                images.add(i)

    allImages = sorted([str(s) for s in set(m.resourceManager(nf='*.png')) | images], key=str.lower)

    if m.window(WINDOW_NAME, exists=True):
        m.deleteUI(WINDOW_NAME)

    m.window(
        WINDOW_NAME,
        t='{} maya icons'.format(len(allImages)),
        w=700,
        h=650
    )

    m.scrollLayout()

    m.rowColumnLayout(
        numberOfColumns=20,
        columnWidth=[
            (1, ICON_WIDTH),
            (2, ICON_WIDTH),
            (3, ICON_WIDTH),
            (4, ICON_WIDTH),
            (5, ICON_WIDTH),
            (6, ICON_WIDTH),
            (7, ICON_WIDTH),
            (8, ICON_WIDTH),
            (9, ICON_WIDTH),
            (10, ICON_WIDTH),
            (11, ICON_WIDTH),
            (12, ICON_WIDTH),
            (13, ICON_WIDTH),
            (14, ICON_WIDTH),
            (15, ICON_WIDTH),
            (16, ICON_WIDTH),
            (17, ICON_WIDTH),
            (18, ICON_WIDTH),
            (19, ICON_WIDTH),
            (20, ICON_WIDTH),
        ]
    )

    for image in allImages:
        cmd = 'print("{}")'.format(image)
        try:
            m.symbolButton(image=image, ann=image, c=cmd, w=35, h=35)
        except StandardError:
            pass

    m.window(
        WINDOW_NAME,
        e=True,
        wh=[712, 656]
    )
    m.showWindow(WINDOW_NAME)
import maya.cmds as cmds

for item in cmds.resourceManager(nameFilter="*png"):
    print(item)
import maya.cmds as cmds

ICONS_FOLDER = 'C:/Users/Audrey/Google Drive/[SCRIPT]/python/maya_script/Adbrower/adb_misc/adb_icons/'

for item in cmds.resourceManager(nf='deleteActive.png'):
    cmds.resourceManager(s=(item, "{}{}".format(ICONS_FOLDER, item)))