示例#1
0
 def addFolder(self, widget):
     file_open_dialog = widgetPresenter.FileDialog('select-folder')
     response = file_open_dialog.run()
     if response == gtk.RESPONSE_OK:
         for folder in file_open_dialog.get_filenames():
             self.__addImagesToReviewer(lib.getImagesFromFolder(folder))
     file_open_dialog.destroy()
示例#2
0
 def addFolder(self, widget):
     file_open_dialog = widgetPresenter.FileDialog('select-folder')
     response = file_open_dialog.run()
     if response == gtk.RESPONSE_OK:
         for folder in file_open_dialog.get_filenames():
             self.__addImagesToReviewer(lib.getImagesFromFolder(folder))
     file_open_dialog.destroy()
示例#3
0
 def importPdf(self, widget):
     file_open_dialog = widgetPresenter.FileDialog('open', file_filters = [(_('PDF'), ['application/pdf'], [])])
     response = file_open_dialog.run()
     if response == gtk.RESPONSE_OK:
         for file_name in file_open_dialog.get_filenames():
             folder = lib.convertPdfToImages(file_name, self.configuration_manager.getTemporaryDir())
             self.__addImagesToReviewer(lib.getImagesFromFolder(folder))
     file_open_dialog.destroy()
示例#4
0
 def importPdf(self, widget):
     file_open_dialog = widgetPresenter.FileDialog(
         'open', file_filters=[(_('PDF'), ['application/pdf'], [])])
     response = file_open_dialog.run()
     if response == gtk.RESPONSE_OK:
         for file_name in file_open_dialog.get_filenames():
             folder = lib.convertPdfToImages(
                 file_name, self.configuration_manager.getTemporaryDir())
             self.__addImagesToReviewer(lib.getImagesFromFolder(folder))
     file_open_dialog.destroy()
示例#5
0
 def __init__(self):
     
     # i18n
     languages = []
     lc, encoding = locale.getdefaultlocale()
     if lc:
         languages = [lc]
     languages += DEFAULT_LANGUAGES
     gettext.bindtextdomain(OCRFEEDER_COMPACT_NAME, LOCALE_DIR)
     gettext.textdomain(OCRFEEDER_COMPACT_NAME)
     language = gettext.translation(OCRFEEDER_COMPACT_NAME, LOCALE_DIR,
                                    languages = languages, fallback = True)
     _ = language.gettext
     self.title = OCRFEEDER_STUDIO_NAME
     self.main_window = widgetPresenter.MainWindow()
     self.main_window.setTitle(self.title)
     cli_command_retriever = ArgsRetriever(sys.argv)
     imgs = cli_command_retriever.getParams('--images')
     self.configuration_manager = ConfigurationManager()
     self.ocr_engines_manager = OcrEnginesManager(self.configuration_manager)
     self.ocr_engines_manager.makeEnginesFromFolder(self.configuration_manager.user_engines_folder)
     self.ocr_engines = self.ocr_engines_manager.ocr_engines
     self.configuration_manager.loadConfiguration()
     self.source_images_selector = SourceImagesSelector(imgs)
     self.source_images_selector.connect('selection_changed', self.selectionChanged)
     self.source_images_icon_view = SourceImagesSelectorIconView(self.source_images_selector)
     self.source_images_icon_view.setDeleteCurrentPageFunction(self.deleteCurrentPage)
     self.source_images_icon_view.show()
     self.main_window.main_area_left.add_with_viewport(self.source_images_icon_view)
     self.images_selectable_area = {}
     self.images_dict = create_images_dict_from_liststore(self.source_images_selector.list_store)
     self.source_images_controler = ImageReviewer_Controler(self.main_window.notebook, self.images_dict, self.source_images_icon_view, self.ocr_engines, self.configuration_manager, self.main_window.tripple_statusbar)
     self.project_name = None
     
     toolbar_callback_dict = {'detection': self.source_images_controler.performBoxDetection,
                      'export_to_odt': self.exportToOdt}
     
     menubar_callback_dict = {'exit': self.quit, 'add_image': self.addImage, 'export_to_odt': self.exportToOdt, 'edit_page': self.choosePageSize,
                              'delete_page': self.deleteCurrentPage, 'export_dialog': self.exportDialog, 'add_folder': self.addFolder, 
                              'import_pdf': self.importPdf, 'save_project': self.saveProject, 'save_project_as': self.saveProjectAs,
                              'open_project': self.openProject, 'append_project': self.appendProject,'clear': self.clear,
                              'unpaper': self.unpaper, 'preferences': self.preferences, 'about': self.about,
                              'ocr_engines': self.ocrEngines, 'zoom_in': self.zoomIn, 'zoom_out': self.zoomOut,
                              'zoom_fit': self.zoomFit, 'reset_zoom': self.resetZoom}
     
     self.main_window.setHeader(menubar_callback_dict, toolbar_callback_dict)
     self.main_window.setDestroyEvent(self.quit)
     
     dirs = cli_command_retriever.getParams('--dir')
     if dirs:
         self.__addImagesToReviewer(lib.getImagesFromFolder(dirs[0]))
     
     self.main_window.setHasImages(not self.source_images_selector.isEmpty())
示例#6
0
    def __init__(self):

        # i18n
        languages = []
        lc, encoding = locale.getdefaultlocale()
        if lc:
            languages = [lc]
        languages += DEFAULT_LANGUAGES
        gettext.bindtextdomain(OCRFEEDER_COMPACT_NAME, LOCALE_DIR)
        gettext.textdomain(OCRFEEDER_COMPACT_NAME)
        language = gettext.translation(OCRFEEDER_COMPACT_NAME,
                                       LOCALE_DIR,
                                       languages=languages,
                                       fallback=True)
        _ = language.gettext
        self.title = OCRFEEDER_STUDIO_NAME
        self.main_window = widgetPresenter.MainWindow()
        self.main_window.setTitle(self.title)
        cli_command_retriever = ArgsRetriever(sys.argv)
        imgs = cli_command_retriever.getParams('--images')
        self.configuration_manager = ConfigurationManager()
        self.ocr_engines_manager = OcrEnginesManager(
            self.configuration_manager)
        self.ocr_engines_manager.makeEnginesFromFolder(
            self.configuration_manager.user_engines_folder)
        self.ocr_engines = self.ocr_engines_manager.ocr_engines
        self.configuration_manager.loadConfiguration()
        self.source_images_selector = SourceImagesSelector(imgs)
        self.source_images_selector.connect('selection_changed',
                                            self.selectionChanged)
        self.source_images_icon_view = SourceImagesSelectorIconView(
            self.source_images_selector)
        self.source_images_icon_view.setDeleteCurrentPageFunction(
            self.deleteCurrentPage)
        self.source_images_icon_view.show()
        self.main_window.main_area_left.add_with_viewport(
            self.source_images_icon_view)
        self.images_selectable_area = {}
        self.images_dict = create_images_dict_from_liststore(
            self.source_images_selector.list_store)
        self.source_images_controler = ImageReviewer_Controler(
            self.main_window.notebook, self.images_dict,
            self.source_images_icon_view, self.ocr_engines,
            self.configuration_manager, self.main_window.tripple_statusbar)
        self.project_name = None

        toolbar_callback_dict = {
            'detection': self.source_images_controler.performBoxDetection,
            'export_to_odt': self.exportToOdt
        }

        menubar_callback_dict = {
            'exit': self.quit,
            'add_image': self.addImage,
            'export_to_odt': self.exportToOdt,
            'edit_page': self.choosePageSize,
            'delete_page': self.deleteCurrentPage,
            'export_dialog': self.exportDialog,
            'add_folder': self.addFolder,
            'import_pdf': self.importPdf,
            'save_project': self.saveProject,
            'save_project_as': self.saveProjectAs,
            'open_project': self.openProject,
            'append_project': self.appendProject,
            'clear': self.clear,
            'unpaper': self.unpaper,
            'preferences': self.preferences,
            'about': self.about,
            'ocr_engines': self.ocrEngines,
            'zoom_in': self.zoomIn,
            'zoom_out': self.zoomOut,
            'zoom_fit': self.zoomFit,
            'reset_zoom': self.resetZoom
        }

        self.main_window.setHeader(menubar_callback_dict,
                                   toolbar_callback_dict)
        self.main_window.setDestroyEvent(self.quit)

        dirs = cli_command_retriever.getParams('--dir')
        if dirs:
            self.__addImagesToReviewer(lib.getImagesFromFolder(dirs[0]))

        self.main_window.setHasImages(
            not self.source_images_selector.isEmpty())