Ejemplo n.º 1
0
	def closeAll(self):
		leafItems = self.getTreeLeafItems()

		for i in range(len(leafItems)):
			sToolFileName = leafItems[i].text(2)

			sToolName = leafItems[i].text(0)
			sType = main.getPyFileType(sToolFileName)

			if sType == "tool":
				bOpened = utils.isToolOpened(sToolName)
				if bOpened:
					isDockable = utils.isToolDockable(sToolName)
					utils.closeTool(sToolName, dock=isDockable)
				else:
					utils.closeTool(sToolName)

				# leafItems[i].setBackground(1, QtGui.QBrush(self.openStateColor))
				leafItems[i].setIcon(1, self.toolIcon)
				leafItems[i].setForeground(1, QtGui.QBrush(self.foregroundColor))
				leafItems[i].setText(1, "Open")
Ejemplo n.º 2
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)