Пример #1
0
 def OnAddWordToGroupFromList(self, evt):
     selections = self.lb1.GetSelections()
     db_group = Group.get_groups(self.select_group.Items[self.select_group.Selection])[0]
     for selection in selections: 
         db_word = Word.get_words(word=self.lb1.Items[selection])[0]
         word_group = WordGroupAssociation(word_id=db_word.id, group_id=db_group.id)
         session.add(word_group)
         session.commit()
         self.group_words.Append(db_word.word)
Пример #2
0
 def onRemoveWordFromGroup(self, evt):
     selection = self.group_words.GetSelection()
     word = self.group_words.Items[selection]
     db_word = Word.get_words(word)[0]
     db_group = Group.get_groups(self.select_group.Items[self.select_group.Selection])[0]
     self.group_words.Delete(selection)
     db_wga = session.query(WordGroupAssociation).filter_by(group_id=db_group.id, word_id=db_word.id).first()
     session.delete(db_wga)
     session.commit()
Пример #3
0
    def onAddWordToGroup(self, evt):
        name = self.select_group.Items[self.select_group.Selection]
        group = Group.get_groups(name)[0]
        dlg = wx.TextEntryDialog(
                self, 'Please enter the word to add:')


        if dlg.ShowModal() == wx.ID_OK:
            word = dlg.GetValue()
            db_word = Word.add_word(word)
            word_group = WordGroupAssociation(word_id=db_word.id, group_id=group.id)
            session.add(word_group)
            session.commit()
            self.group_words.Append(word)
        dlg.Destroy()