def on_unfilter_button(self, *args, **kwargs): #work backwards through the list clearing one for each call, #find the first one that has a selection backwards_list = [self.rating_listbox, \ self.folder_listbox, \ self.month_listbox, \ self.year_listbox] self.revese_listdict = dict((v,k) for k, v in self.listdict.iteritems()) for listbox in backwards_list: selected = listbox.get_selected() if selected != []: attr = self.revese_listdict[listbox] listbox.clear_selected() #this almost works, but self.filtered_data needs to be reset self.filter_data(filter_boxes=False) self._upate_total_filtered() self.filter_one_listbox(listbox, attr) break
def build_boolvect(self): N = len(self.db.photo_id) boolvect = numpy.ones(N).astype(bool) force_str_list = ['rating'] for attr, listbox in self.listdict.iteritems(): selected = listbox.get_selected() if selected != []: data = getattr(self.db, attr) if attr in force_str_list: data = data.astype(str) itembool = numpy.zeros(N).astype(bool) for item in selected: if attr == 'rating' and item == 'Unrated': curbool = self.get_unrated_images(data) else: curbool = data == item itembool = itembool | curbool boolvect = boolvect & itembool self.boolvect = boolvect return boolvect
def filter_listboxes(self): """Filter any listboxes that don't have any items selected.""" for attr, listbox in self.listdict.iteritems(): selected = listbox.get_selected() if not selected: self.filter_one_listbox(listbox, attr)