[ocrfeeder/langs: 12/15] Add new language settings to the OcrEnginesManager and OcrSettingsDialog
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder/langs: 12/15] Add new language settings to the OcrEnginesManager and OcrSettingsDialog
- Date: Tue, 5 Feb 2013 06:25:44 +0000 (UTC)
commit a7636ee370c68ad2452f9a11aa3f693cbac866b1
Author: Joaquim Rocha <jrocha igalia com>
Date: Fri Feb 1 14:47:47 2013 +0100
Add new language settings to the OcrEnginesManager and OcrSettingsDialog
src/ocrfeeder/feeder/ocrEngines.py | 5 ++++-
src/ocrfeeder/studio/widgetPresenter.py | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/src/ocrfeeder/feeder/ocrEngines.py b/src/ocrfeeder/feeder/ocrEngines.py
index f544fec..0e45e13 100644
--- a/src/ocrfeeder/feeder/ocrEngines.py
+++ b/src/ocrfeeder/feeder/ocrEngines.py
@@ -261,11 +261,14 @@ class OcrEnginesManager:
return [os.path.join(folder, file) for file in os.listdir(folder) if file.endswith('.xml')]
def newEngine(self, name, engine_path, arguments,
- image_format, failure_string, version):
+ image_format, failure_string, languages,
+ language_argument, version):
engine = Engine(name = name, engine_path = engine_path,
arguments = arguments, image_format = image_format,
temporary_folder = self.configuration_manager.TEMPORARY_FOLDER,
failure_string = failure_string,
+ languages = languages,
+ language_argument = language_argument,
version = version)
return engine
diff --git a/src/ocrfeeder/studio/widgetPresenter.py b/src/ocrfeeder/studio/widgetPresenter.py
index 9213b08..71835b4 100644
--- a/src/ocrfeeder/studio/widgetPresenter.py
+++ b/src/ocrfeeder/studio/widgetPresenter.py
@@ -1849,12 +1849,16 @@ class OcrSettingsDialog(gtk.Dialog):
engine_path = ''
failure_string = ''
arguments = '$IMAGE'
+ language_argument = ''
+ languages = ''
if self.engine:
name = self.engine.name
image_format = self.engine.image_format
failure_string = self.engine.failure_string
engine_path = self.engine.engine_path
arguments = self.engine.arguments
+ language_argument = self.engine.language_argument
+ languages = self.engine.serializeLanguages(self.engine.languages)
box = gtk.VBox(True, 0)
size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
self.name_entry = gtk.Entry()
@@ -1878,6 +1882,25 @@ class OcrSettingsDialog(gtk.Dialog):
self.arguments_entry, arguments,
_('Arguments: use $IMAGE for image '
'and $FILE if it writes to a file'))
+ self.language_argument_entry = gtk.Entry()
+ self.__packSettingInFrame(box, size_group,
+ _('Engine _language argument:'),
+ self.language_argument_entry, language_argument,
+ _('The language argument in case this engine '
+ 'uses it (for example "-l"). In order for '
+ 'it to work, the engine\'s arguments should '
+ 'have the $LANG keyword.'))
+ self.languages_entry = gtk.Entry()
+ self.__packSettingInFrame(box, size_group,
+ _('Engine lan_guages:'),
+ self.languages_entry, languages,
+ _('The languages this engine supports. '
+ 'This should be given as pairs of the '
+ 'language in the ISO 639-1 and the '
+ 'engine\'s corresponding language '
+ '(for example "en:eng,pt:por,es:esp"). '
+ 'In order for it to work, the engine\'s '
+ 'arguments should have the $LANG keyword.'))
return box
def setEngine(self):
@@ -1895,11 +1918,15 @@ class OcrSettingsDialog(gtk.Dialog):
arguments = self.arguments_entry.get_text()
image_format = self.image_format_entry.get_text()
failure_string = self.failure_string_entry.get_text()
+ languages = self.languages_entry.get_text()
+ language_argument = self.language_argument_entry.get_text()
engine = self.engine_manager.newEngine(self.name_entry.get_text(),
path,
arguments,
image_format,
failure_string,
+ languages,
+ language_argument,
version)
if self.engine:
self.engine_manager.replaceEngine(self.engine, engine)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]