代码: 全选
/home/liu/code/panda/aMonpoly/PaletteTreeCtrl.py:41: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if parentItemName == items[key]:
[python] #-*- coding: utf-8 -*-
"""
Defines Palette tree control
"""
import wx
import cPickle as pickle
from ObjectPaletteBase import *
class PaletteTreeCtrl(wx.TreeCtrl):
def __init__(self, parent, treeStyle, rootName):
wx.TreeCtrl.__init__(self, parent, style=treeStyle)
self.rootName = rootName
self.root = self.AddRoot(self.rootName)
self.paletteUI = parent
self.opSortAlpha = "Sort Alphabetical Order"
self.opSortOrig = "Sort Original Order"
self.opSort = self.opSortOrig
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.onBeginDrag)
def OnCompareItems(self, item1, item2):
return self.paletteUI.compareItems(item1, item2)
def SortTreeNodes(self, parent):
self.SortChildren(parent)
item, cookie = self.GetFirstChild(parent)
while item:
if self.ItemHasChildren(item):
self.SortTreeNodes(item)
# continue iteration to the next child
item, cookie = self.GetNextChild(parent, cookie)
def addTreeNodes(self, parentItem, parentItemName, items, itemKeys):
roots = []
rootItems = []
for key in itemKeys:
if parentItemName == items[key]:
print parentItemName,items[key]
roots.append(key)
for root in roots:
newItem = self.AppendItem(parentItem, root)
self.SetItemPyData(newItem, root)
rootItems.append(newItem)
itemKeys.remove(root)
for rootItem in rootItems:
self.addTreeNodes(rootItem, self.GetItemText(rootItem), items, itemKeys) [/python]
问题解决了。
if parentItemName.encode('utf-8') == items[key]: