import maya
import sys
import os
from functools import partial
import maya.cmds as cmds

def customVer(FileName, version):
#create a file path with the file you have and version you want 
    version = 9000+int(FileName[(location-3):location])
    newFileName = str((myFileName[0:(location-3)]))
    version = str(version-1)
    version = version[1:]
    newFileName = newFileName+str(version)
    return newFileName

def newFile(myFileName):
#find what the file path would be for the next version

    #find version number (with 9 at front) of file currently being referenced to
        version = 9000+int(myFileName[(location-3):location])

    #find what the file path would be with no number at end
    newFileName = str((myFileName[0:(location-3)]))

    #find next version number
    version = str(version+1)
    #take out 9 (start from second term)
    version = version[1:]

    newFileName = newFileName+str(version)

    return newFileName

def refUpdate(inst = None, new = '', old = '', window = ''):
#replace old reference with updated reference (with new version)

    window = unicode(window)
    cmds.file( new, r=True)
    cmds.file( old, rr = True)
    cmds.deleteUI(window, window=True)

def main(myFileName):
#find what new filepath name would be. if it's not updated, give an option to update...if it is updated...give option to close

    newFileName = newFile(myFileName)
    fileList = myFileName

    #if path exists
    if os.path.isdir(newFileName):
        print "THERE IS A NEWER VERSION!"
        while os.path.isdir(newFileName) != False:
            newFileName = newFile(newFileName)
            highest_version = int(newFileName[(len(newFileName)-3):len(newFileName)])-1

        #pathname for highest version
        newFileName = customVer(newFileName, highest_version)
        fileList = fileList[(location):len(fileList)]
        fullName = str(newFileName+fileList)

        window = cmds.window( title="Check for Updates", iconName='UpdateChecker', width=400, height=100 )
        cmds.columnLayout( )
        cmds.button( label='Latest version of ' + name + ' is Version '+ str(highest_version)+". Click to update reference.", command = partial(refUpdate, new = fullName, old = myFileName, window = str(window)))     
        cmds.setParent( '..' )
        cmds.showWindow( window )
        window = cmds.window( title="Check for Updates", iconName='UpdateChecker', width=300, height=30 )
        cmds.columnLayout( )
        cmds.button( label='You currently have the latest version of ' + name + '. Click to close', align = 'center', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
        cmds.setParent( '..' )
        cmds.showWindow( window )       
        print "NO NEWER VERSION!"

refsList =  cmds.file(q = True, list = True)
references = []
for i in refsList:
    if i.find('.ma') != -1:
for elements in references:
    location = elements.rfind("/")
    name = elements[(location+1):len(elements)]
    myFileName = elements

So what I'm wanting to do here is have it so that a button is added for each loop into a main general window (this would be done at the bottom) at the end of it I would have one window with as many buttons as necessary. What I have now is a bunch of seperate popup windows coming up each time. Any help?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.