Reputation: 433
In simple terms , I am building a toy task manager with wxpython and psutil. I have a searchCtrl on top of the list. But I couldn't find a way to show only the matched items in that the list. I tried creating a list of all tasks and then deleting all items but the matched items , but unfortunately that doesn't work as the list was getting updated every 5 seconds.
def on_search_task(self , e): # this function got executed when the a search event is fired
index = 0
keepitems = []
for x in self.alltasks:
for a in dict(x).values():
if a.find(e.GetString()) >= 0:
print("match at {} - {}".format(index , self.alltasks.index(x)))
print(self.alltasks.index(x) == index)
else:
keepitems.append(index)
index += 1
for x in keepitems:
self.task_list.DeleteItem(x)
I hope I was able to describe the problem and my goal. Source code with current progress is also available on GitHub here https://github.com/bauripalash/taskboy for further reference.
Upvotes: 0
Views: 527