def _insert(self, x, y, text):
""" Insert text at given x, y coordinates --- used with drag-and-drop. """
# Clean text.
import string
text = filter(lambda x: x in (string.letters + string.digits + string.punctuation + ' '), text)
# Find insertion point.
index, flags = self.HitTest((x, y))
if index == wx.NOT_FOUND:
if flags & wx.LIST_HITTEST_NOWHERE:
index = self.GetItemCount()
else:
return
# Get bounding rectangle for the item the user is dropping over.
rect = self.GetItemRect(index)
# If the user is dropping into the lower half of the rect, we want to insert _after_ this item.
if y > rect.y + rect.height/2:
index += 1
self.InsertStringItem(index, text)
评论列表
文章目录