Ejemplo n.º 1
0
def openTool(toolName, module=None):
	if module == None: module = mayaWindow.findChild(QtGui.QDialog, toolName)
	if module == None:
		importStatement = main.getPyFileFullImportName(sToolFileName)
		module = importlib.import_module(importStatement)

	toolFunctions = inspector.getModFunctions(module)
	for tf in toolFunctions:
		if (tf == "run") or (tf.lower() == (toolName.lower() + "run")):
			getattr(module, tf)()
Ejemplo n.º 2
0
def executeScript(scriptName, module=None):
	if module == None: module = mayaWindow.findChild(QtGui.QDialog, scriptName)
	if module == None:
		importStatement = main.getPyFileFullImportName(sToolFileName)
		module = importlib.import_module(importStatement)

	scriptFunctions = inspector.getModFunctions(module)
	for sf in scriptFunctions:
		if (sf == "run") or (sf.lower() == (scriptName.lower() + "run")):
			getattr(module, sf)()
Ejemplo n.º 3
0
	def treeItemExecution(self, item, column):
		if item.childCount() == 0:
			sToolName = item.text(0)
			sToolFileName = item.text(2)

			sType = main.getPyFileType(sToolFileName)
			# oModule = utils.importModule(sToolName)
			importStatement = main.getPyFileFullImportName(sToolFileName)
			print sToolFileName
			oModule = importlib.import_module(importStatement)

			# If the module can be run or closed
			if sType == "tool":
				bOpened = utils.isToolOpened(sToolName)

				# run or close the tool
				if bOpened:
					isDockable = utils.isToolDockable(sToolName)
					utils.closeTool(sToolName, dock=isDockable)
				else: utils.openTool(sToolName, module=oModule)

				# if the module is a tool the Open/Close label must be updated
				bOpened = utils.isToolOpened(sToolName)

				if bOpened:
					# item.setBackground(1, QtGui.QBrush(self.closeStateColor))
					item.setForeground(1, QtGui.QBrush(self.closeStateColor))
					item.setIcon(1, self.toolOpenIcon)
					item.setText(1, "Close")
				else:
					# item.setBackground(1, QtGui.QBrush(self.openStateColor))
					item.setForeground(1, QtGui.QBrush(self.foregroundColor))
					item.setIcon(1, self.toolIcon)
					item.setText(1, "Open")

			elif sType == "script":
				utils.executeScript(sToolName, module=oModule)