当前位置: 首页>>代码示例>>Python>>正文


Python Tree.treeBuilder方法代码示例

本文整理汇总了Python中Tree.treeBuilder方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.treeBuilder方法的具体用法?Python Tree.treeBuilder怎么用?Python Tree.treeBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.treeBuilder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeList

# 需要导入模块: import Tree [as 别名]
# 或者: from Tree import treeBuilder [as 别名]

#.........这里部分代码省略.........
			c+=1
			p.exportDb(session,-1)
		session.commit()
	def treeMaker(self):
		self.tree.resetTree()
		layersmap=QgsMapLayerRegistry.instance().mapLayers()
		
		curLayer = self.iface.mapCanvas().currentLayer()
		mc=self.iface.mapCanvas() 
		#self.log("nLayers test.py 194",self.nLayers)
		
		# rimuovo  il layer aggiunto dal plugin openLayers
		#non posso cambiare il dict mentre sono in un ciclo 
		#quindi creo un dict con i soli layers che mi interessano
		dummymap={}
		for key in layersmap.iterkeys():
			if (self.search(str(key),"_g"))or(self.match(str(key),'Cap')):
				dummymap[key]=layersmap[key]
		#self.log("dummymap={0}".format(dummymap),"203 test.py")
		#self.log("layersmap={0}".format(layersmap),"204 test.py")
		#self.log("lunghezza dummy={0}".format(len(dummymap)),"lunghezza original={0}".format(len(layersmap)))
		n=0
		for key in dummymap.iterkeys():

			self.progressBar.setValueOverall(n)
		#	self.log("esamino layers {0}".format(key),"test.py 212")
		#	self.log("type(key {0}".format(type(key))," ###")
			curLayer=layersmap[key]
			chiave=str(key[0:3])
			#aggiungo il layer che verra' usato per selezionare le features sulla mappa
			self.ui_tree.addLayer(str(key)[0:3], curLayer)
			self.analizeLayers(curLayer,chiave.lower(),str(key))
			n+=1
		lista_nodi=self.tree.treeBuilder()
		#self.testExport(lista_nodi)
		#self.exportDb(lista_nodi)
		#creo il file javascript per l'albero
		for i  in lista_nodi:
			if self.ui_tree.albero.topLevelItemCount()<20:
				self.ui_tree.albero.addTopLevelItem(i.getNode())
		#print " nodi dell'albero",self.ui_tree.albero.topLevelItemCount()
		self.ui_tree.etichetta.setText("Italia")
		screen = QtGui.QDesktopWidget().screenGeometry()
		size =  self.ui_tree.geometry()
		self.ui_tree.move((screen.width()/2)-size.width()*2,(screen.height()/2)-size.width())
		self.ui_tree.show()
			
		self.progressBar.close()

	def initGui(self):
		# Create action that will start plugin configuration
		self.action = QAction(QIcon(":/plugins/Albero/icon.png"), \
			"visualizzazione ad albero", self.iface.mainWindow())
		# connect the action to the run method
		QObject.connect(self.action, SIGNAL("triggered()"), self.run)

		# Add toolbar button and menu item
		self.iface.addToolBarIcon(self.action)
		self.iface.addPluginToMenu("&visualizzazione ad albero", self.action)
		
	def search(self,string,pattern):
		"""
		esegue il metodo search su una stringa:
		@param string: stringa da analizzare
		@param string: pattern dell' espressione regolare
		@return: boolean  
开发者ID:arpho,项目名称:mmasgis5,代码行数:70,代码来源:albero.py


注:本文中的Tree.treeBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。