示例#1
0
 def __init__(self, *args, **kwargs):
     """
     Flags:
         - parent: p                (QMainWindow, default:Wrapped Maya main window)
             The parent layout for this control.
     """
     
     # Get the maya main window as a QMainWindow instance.
     parent = kwargs.pop('p', kwargs.pop('parent',
         sip.wrapinstance(long(mui.MQtUtil.mainWindow()), QObject)))
     super(QMainWindow, self).__init__(parent)
     # uic adds a function to our class called setupUi, calling this creates all the
     # widgets from the .ui file.
     self.setupUi(self)
     self.__name__ = self.__class__.__name__
     g_name = 'g%sDocker' % self.__name__
     melGlobals.initVar('string', g_name)
     
     docker = melGlobals[g_name]
     if docker and dockControl(docker, exists=True):
         info('Deleting docker: ' + docker)
         deleteUI(docker, control=True)
     docker = dockControl(allowedArea=['left', 'right'], area='right',
         floating=False, content=self.__name__,
         parent='MayaWindow|formLayout1',
         label=str(self.windowTitle()), width=self.width())
     melGlobals[g_name] = docker.split('|')[-1]
示例#2
0
def init(**kwargs):
    """
	Flags:
		- load_menu: lm						(bool, default:True)
			Loads the Lava menu bar menu to Maya's menu bar.
		
		- signature: s							(unicode, default:None)
			Signs your name onto any new scene's defaultLayer as a locked attribute.
			This is just an extra measure of security to protect your work against
			plagiarism, making it more difficult, but not impossible to plagiarize.
		
		- source_mels: sm					(list, default:[])
			Sources the provided MEL scripts after everything has been initialized
			(e.g. source_mels=['cometMenu'])
		
		- working_drive: wd					(unicode, default:None)
			Sets the drive from which scripts should be loaded. If set to None,
			automatically searches available drives for a lavaWorkingDrive file.
			If the file is found, that drive will be the working drive. This is especially
			useful for temporary drives (e.g. USB drives).
	"""

    # Pop-out all the kwarg flags.
    working_drive = kwargs.pop('wd', kwargs.pop('working_drive', None))
    load_menu = kwargs.pop('lm', kwargs.pop('load_menu', True))
    signature = kwargs.pop('s', kwargs.pop('signature', None))
    source_mels = kwargs.pop('sm', kwargs.pop('source_mels', []))

    # Extend gLavaSourcedMels global with the source_mels kwarg.
    melGlobals.initVar('string', 'gLavaSourcedMels')
    mels = melGlobals['gLavaSourcedMels']
    mels = mels and pickle.loads(mels) or {}
    for m in source_mels:
        if m.endswith('.mel'): m = m[:-4]
        mels[m] = None
    melGlobals['gLavaSourcedMels'] = pickle.dumps(mels)

    # Keep track of how many times the init function has been called.
    melGlobals.initVar('int', 'gLavaInitialized')
    melGlobals['gLavaInitialized'] += 1
    if melGlobals['gLavaInitialized'] == 1:
        _set_working_drive(working_drive)
        if working_drive != sys.modules[__name__].__file__[0]:
            # If the working drive is different than the current module's drive then
            # we want to assume the working drive has the most recent scripts.
            # Reload all the modules to pickup latest scripts.
            rehash_and_reload(verbose=True)
            return False

    if load_menu: executeDeferred(LavaMenu)
    executeDeferred(lambda *args: _source_mels(mels))
    if signature: auto_sign_new_scenes(signature)
示例#3
0
def init(**kwargs):
	"""
	Flags:
		- load_menu: lm						(bool, default:True)
			Loads the Lava menu bar menu to Maya's menu bar.
		
		- signature: s							(unicode, default:None)
			Signs your name onto any new scene's defaultLayer as a locked attribute.
			This is just an extra measure of security to protect your work against
			plagiarism, making it more difficult, but not impossible to plagiarize.
		
		- source_mels: sm					(list, default:[])
			Sources the provided MEL scripts after everything has been initialized
			(e.g. source_mels=['cometMenu'])
		
		- working_drive: wd					(unicode, default:None)
			Sets the drive from which scripts should be loaded. If set to None,
			automatically searches available drives for a lavaWorkingDrive file.
			If the file is found, that drive will be the working drive. This is especially
			useful for temporary drives (e.g. USB drives).
	"""
	
	# Pop-out all the kwarg flags.
	working_drive = kwargs.pop('wd', kwargs.pop('working_drive', None))
	load_menu = kwargs.pop('lm', kwargs.pop('load_menu', True))
	signature = kwargs.pop('s', kwargs.pop('signature', None))
	source_mels = kwargs.pop('sm', kwargs.pop('source_mels', []))
	
	# Extend gLavaSourcedMels global with the source_mels kwarg.
	melGlobals.initVar('string', 'gLavaSourcedMels')
	mels = melGlobals['gLavaSourcedMels']
	mels = mels and pickle.loads(mels) or {}
	for m in source_mels:
		if m.endswith('.mel'): m = m[:-4]
		mels[m] = None
	melGlobals['gLavaSourcedMels'] = pickle.dumps(mels)
	
	# Keep track of how many times the init function has been called.
	melGlobals.initVar('int', 'gLavaInitialized')
	melGlobals['gLavaInitialized'] += 1
	if melGlobals['gLavaInitialized'] == 1:
		_set_working_drive(working_drive)
		if working_drive != sys.modules[__name__].__file__[0]:
			# If the working drive is different than the current module's drive then
			# we want to assume the working drive has the most recent scripts.
			# Reload all the modules to pickup latest scripts.
			rehash_and_reload(verbose=True)
			return False
	
	if load_menu: executeDeferred(LavaMenu)
	executeDeferred(lambda *args: _source_mels(mels))
	if signature: auto_sign_new_scenes(signature)