标签:style blog color os ar div log sp on
下面是递归遍历、获取树节点的方法。
1 def getTreeAllText(self): 2 ‘‘‘获取树控件的全部文本‘‘‘ 3 result = [] 4 treeRoot = self.treeCtrl.GetRootItem() 5 rootText = self.treeCtrl.GetItemText(treeRoot) 6 result.append(u‘┌‘+rootText) 7 def recursivelyGetTreeItem(tree,leval): 8 ‘‘‘ 递归遍历TreeCtrl的所有孩子 ‘‘‘ 9 (item,cookie) = self.treeCtrl.GetFirstChild(tree) 10 while item.IsOk(): 11 ItemStr = u‘├%s%s‘ % (u‘─‘*leval,self.treeCtrl.GetItemText(item)) 12 result.append(ItemStr) 13 if self.treeCtrl.GetChildrenCount(item)>0: 14 leval+=1 15 recursivelyGetTreeItem(item,leval) 16 leval-=1 17 (item,cookie) = self.treeCtrl.GetNextChild(item,cookie) 18 19 leval = 0 #递归的子树层次 20 recursivelyGetTreeItem(treeRoot,leval) 21 return ‘\n‘.join(result)
设置文本内容到剪贴板
1 def CopyToClipboard(text): 2 do = wx.TextDataObject() 3 do.SetText(text.encode(‘gb2312‘)) 4 if wx.TheClipboard.Open(): 5 wx.TheClipboard.SetData(do) 6 wx.TheClipboard.Close() 7 else: 8 wx.MessageBox("Unable to open the clipboard", "Error")
标签:style blog color os ar div log sp on
原文地址:http://www.cnblogs.com/ajucs/p/3949419.html