def OnAddKW(self, evt): """Invoked when the user activates the Add Keyword (>>) button.""" # For each selected Keyword ... for item in self.kw_lb.GetSelections(): # ... get the keyword group name ... kwg_name = self.kw_group_lb.GetStringSelection() # ... get the keyword name ... kw_name = self.kw_lb.GetString(item) # ... build the kwg : kw combination ... ep_kw = "%s : %s" % (kwg_name, kw_name) # We need to check to see if the keyword is already in the keyword list keywordFound = False # Iterate through the list for clipKeyword in self.keywords: # If we find a match, set the flag and quit looking. if (clipKeyword.keywordGroup == kwg_name) and (clipKeyword.keyword == kw_name): keywordFound = True break # If the keyword is not found, add it. (If it's already there, we don't need to do anything!) if not keywordFound: # Create an appropriate ClipKeyword Object tempClipKeyword = ClipKeywordObject.ClipKeyword( kwg_name, kw_name) # Add it to the Keyword List self.keywords.append(tempClipKeyword) self.ekw_lb.Append(ep_kw)
def refresh_keywords(self): """Clear the keyword list and refresh it from the database.""" self._kwlist = [] kwpairs = DBInterface.list_of_keywords(Episode=self.number) for data in kwpairs: tempClipKeyword = ClipKeywordObject.ClipKeyword(data[0], data[1], episodeNum=self.number, example=data[2]) self._kwlist.append(tempClipKeyword)
def add_keyword(self, kwg, kw): """Add a keyword to the keyword list.""" # We need to check to see if the keyword is already in the keyword list keywordFound = False # Iterate through the list for episodeKeyword in self._kwlist: # If we find a match, set the flag and quit looking. if (episodeKeyword.keywordGroup == kwg) and (episodeKeyword.keyword == kw): keywordFound = True break # If the keyword is not found, add it. (If it's already there, we don't need to do anything!) if not keywordFound: # Create an appropriate ClipKeyword Object tempClipKeyword = ClipKeywordObject.ClipKeyword(kwg, kw, episodeNum=self.number) # Add it to the Keyword List self._kwlist.append(tempClipKeyword)