def onExit(self, event): # make sure all words are saved opened_words = [word for word in \ registry.top_package.word_dict.values() \ if word.save_state == False] if len(opened_words): dlg = ConfirmSaveDialog(None, -1, "Do you want to save the " \ "currently opened words?", \ size=(350, 200)) val = dlg.ShowModal() if val == wx.ID_SAVE: debug.notice("Saving Words") for word in opened_words: word.save() elif val == wx.ID_NO: debug.notice("Not Saving Words") else: dlg.Destroy() return dlg.Destroy() event.Skip()
def buildWord(self): debug.trace("RightMainPanel.buildWord") # setup word controls if registry.currentWord: for question in registry.currentWord.kind_obj.questions or (): self.topSizer.Add(wx.StaticText(self.topPanel, -1, \ "%s: " % question.label)) if not hasattr(question, 'control'): msg = "<%s %s> has no control" % \ (question.__class__.__name__, question.name) debug.warn(msg) self.topSizer.Add(wx.StaticText(self.topPanel, -1, msg)) else: cls = getattr(controls, question.control) debug.trace('%s is being renderd as %s' % \ (question.name, cls.__name__)) self.topSizer.Add( cls.makeControl( self.topPanel, question, lambda question=question: registry.currentWord.get_answer(question.name), lambda new_ans, question=question: registry.currentWord.set_answer(question.name, new_ans))) # setup bottom text self.bottomText.ClearAll() source_filename = registry.currentWord.get_filename() if source_filename and os.path.exists(source_filename): if registry.currentWord.source_text: self.bottomText.SetText(registry.currentWord.source_text) debug.trace('loaded from source_text') else: self.bottomText.LoadFile(source_filename) debug.trace('loaded from file') else: debug.notice('No word currently selected')
def change(self, value): registry.currentWord.set_save_state(False) self.ans_getter().value = str(value) debug.notice("%s changed: %s" % (self.__class__.__name__, value))
def onBottomTextChange(self, event): debug.notice('BottomTextCtrlL: Update event!') registry.currentWord.source_text = self.GetText() registry.currentWord.set_save_state(False) event.Skip() # CLEAN not sure if this is needed