Beispiel #1
0
    def onSave(self, event):
        """Apply changes"""

        parent = self.GetParent()
        word = enc.fromWX(self.entryWord.GetValue())

        translations = []

        for label in self.textEntries.values():
            translations.append(enc.fromWX(label.GetValue()))

        transcomm = {}

        for translation in translations:
            if not len(translation.strip()):
                continue
            chunks = translation.split('//', 1)
            if len(chunks) == 2:
                t = chunks[0]
                c = chunks[1]
            else:
                t = chunks[0]
                c = None

            transcomm[t] = c

        parent.editor.getUnit(word).setTranslations(transcomm)
        parent.setChanged(True)
        parent.checkAllButtons()

        self.Destroy()
Beispiel #2
0
    def onSave(self, event):
        """Apply changes"""

        parent = self.GetParent()
        word = enc.fromWX(self.entryWord.GetValue())

        translations = []

        for label in self.textEntries.values():
            translations.append(enc.fromWX(label.GetValue()))

        transcomm = {}

        for translation in translations:
            if not len(translation.strip()):
                continue
            chunks = translation.split('//', 1)
            if len(chunks) == 2:
                t = chunks[0]
                c = chunks[1]
            else:
                t = chunks[0]
                c = None

            transcomm[t] = c

        parent.editor.getUnit(word).setTranslations(transcomm)
        parent.setChanged(True)
        parent.checkAllButtons()

        self.Destroy()
Beispiel #3
0
    def OnLinkClicked(self, linkInfo):

        global lastLookupWord
        lastLookupWord = linkInfo.GetHref()
        wx.BeginBusyCursor()
        parent = self.GetParent().GetParent().GetParent()

        word = enc.fromWX(lastLookupWord)
        try:
            word = word.encode(parent.activeDictionary.getEncoding())
        except Exception as e:
            # FIXME: Code duplicates
            traceback.print_exc()
            parent.buttonStop.Disable()
            parent.entry.Enable(True)
            parent.timerSearch.Stop()
            parent.SetStatusText(_('Stopped'))
            wx.EndBusyCursor()

            systemLog(ERROR,
                      "Unable to decode '%s': %s" % (word.encode('UTF-8'), e))
            title = _("Encode Failed")
            msg = _("Unable to encode text \"%s\" in %s for \"%s\".") \
                    % (enc.toWX(word), parent.activeDictionary.getEncoding(),
                    parent.activeDictionary.getName())

            errorwin.showErrorMessage(title, msg)

            return

        parent.SetStatusText(_("Searching..."))
        parent.entry.SetValue(word)
        parent.timerSearch.Start(parent.delay)
        parent.search = Process(parent.activeDictionary.search, word)
Beispiel #4
0
    def onWordSelected(self, event):
        """Is called when word list item is selected"""

        if self.search and not self.search.isDone():
            return

        self.__searchedBySelecting = 1
        self.SetStatusText(_("Searching..."))
        self.buttonStop.Enable(1)
        self.timerSearch.Start(self.delay)
        word = event.GetString()
        global lastLookupWord
        lastLookupWord = word
        self.entry.SetValue(word)
        word = enc.fromWX(word)
        word = word.encode(self.activeDictionary.getEncoding())
        self.search = Process(self.activeDictionary.search, word)
        wx.BeginBusyCursor()
Beispiel #5
0
    def onOK(self, event):
        """Save configuration in the configuration object"""

        self.app.config.set('defaultDict',
                            enc.fromWX(self.dictChooser.GetValue()))

        self.app.config.set('encoding', encodings[self.encChooser.GetValue()])
        if self.app.window.activeDictionary == None:
            self.app.window.checkEncMenuItem(self.app.config.get('encoding'))

        self.app.config.set('dictServer', self.serverEntry.GetValue())
        self.app.config.set('dictServerPort', self.portEntry.GetValue())

        self.app.config.set('pronunciationCommand', self.entryPron.GetValue())
        self.app.config.set('pronounceTrans', str(self.rbPronTrans.GetValue()))

        self.app.config.set('saveWindowSize', str(self.winSize.GetValue()))
        self.app.config.set('saveWindowPos', str(self.winPos.GetValue()))
        self.app.config.set('saveSashPos', str(self.sashPos.GetValue()))
        self.app.config.set('useClipboard', str(self.clipboard.GetValue()))

        frame = self.GetParent()
        if self.app.config.get('saveWinSize'):
            self.app.config.set('windowWidth', frame.GetSize()[0])
            self.app.config.set('windowHeight', frame.GetSize()[1])
        if self.app.config.get('saveWindowPos'):
            self.app.config.set('windowPosX', frame.GetPosition()[0])
            self.app.config.set('windowPosY', frame.GetPosition()[1])

        if self.app.config.get('saveSashPos'):
            if not frame.wordListHidden():
                self.app.config.set('sashPos',
                                    frame.splitter.GetSashPosition())

        self.app.config.save()

        self.Destroy()
Beispiel #6
0
   def onOK(self, event):
      """Save configuration in the configuration object"""

      self.app.config.set('defaultDict',
                          enc.fromWX(self.dictChooser.GetValue()))

      self.app.config.set('encoding', encodings[self.encChooser.GetValue()])
      if self.app.window.activeDictionary == None:
         self.app.window.checkEncMenuItem(self.app.config.get('encoding'))
      
      self.app.config.set('dictServer', self.serverEntry.GetValue())
      self.app.config.set('dictServerPort', self.portEntry.GetValue())
      
      self.app.config.set('pronunciationCommand', self.entryPron.GetValue())
      self.app.config.set('pronounceTrans', str(self.rbPronTrans.GetValue()))

      self.app.config.set('saveWindowSize', str(self.winSize.GetValue()))
      self.app.config.set('saveWindowPos', str(self.winPos.GetValue()))
      self.app.config.set('saveSashPos', str(self.sashPos.GetValue()))
      self.app.config.set('useClipboard', str(self.clipboard.GetValue()))

      frame = self.GetParent()
      if self.app.config.get('saveWinSize'):
         self.app.config.set('windowWidth', frame.GetSize()[0])
         self.app.config.set('windowHeight', frame.GetSize()[1])
      if self.app.config.get('saveWindowPos'):
         self.app.config.set('windowPosX', frame.GetPosition()[0])
         self.app.config.set('windowPosY', frame.GetPosition()[1])

      if self.app.config.get('saveSashPos'):
         if not frame.wordListHidden():
            self.app.config.set('sashPos', frame.splitter.GetSashPosition())

      self.app.config.save()
      
      self.Destroy()
Beispiel #7
0
    def onSearch(self, event):
        if self.activeDictionary == None:
            if len(self.app.dictionaries):
                title = _("No dictionary activated")
                msg = _("No dictionary activated. Please select one from "\
                     "\"Dictionaries\" menu and try again.")
            else:
                title = _("No dictionaries installed")
                msg = _("There is no dictionaries installed. You can " \
                          "install one by selecting Tools > Manage " \
                          "Dictionaries > Available")

            errorwin.showErrorMessage(title, msg)
            return

        if self.search and not self.search.isDone():
            self.onStop(None)

        word = self.entry.GetValue().strip()

        if word == "":
            self.SetStatusText(_("Please enter some text and try again"))
            self.entry.SetFocus()
            return

        global lastLookupWord
        lastLookupWord = word
        wx.BeginBusyCursor()

        self.__searchedBySelecting = 0
        self.SetStatusText(_("Searching..."))

        self.timerSearch.Stop()
        self.search = None

        self.buttonStop.Enable(1)
        self.entry.Disable()
        self.timerSearch.Start(self.delay)

        word = enc.fromWX(word)
        try:
            word = word.encode(self.activeDictionary.getEncoding())
        except Exception as e:
            # FIXME: Code duplicates
            self.buttonStop.Disable()
            self.entry.Enable(True)
            self.timerSearch.Stop()
            self.SetStatusText(_('Stopped'))
            wx.EndBusyCursor()

            systemLog(ERROR,
                      "Unable to decode '%s': %s" % (word.encode('UTF-8'), e))
            title = _("Encode Failed")
            msg = _("Unable to encode text \"%s\" in %s for \"%s\". "
                    "That logically means the word "
                    "definition does not exist in the dictionary.") \
                    % (enc.toWX(word), self.activeDictionary.getEncoding(),
                    self.activeDictionary.getName())

            errorwin.showErrorMessage(title, msg)

            return

        self.search = Process(self.activeDictionary.search, word)