Exemplo n.º 1
0
 def __askForFileName(self, extension=''):
     save_dialog = FileDialog('save')
     response = save_dialog.run()
     if response == gtk.RESPONSE_OK:
         file_name = save_dialog.get_filename()
         if extension:
             if not file_name.endswith(extension):
                 file_name += extension
         if os.path.isfile(file_name):
             confirm_overwrite = gtk.MessageDialog(
                 type=gtk.MESSAGE_QUESTION)
             message = _(
                 '<b>A file named "%(name)s" already exists. Do you want '
                 'to replace it?</b>\n\nThe file exists in "%(dir)s". '
                 'Replacing it will overwrite its contents.' % {
                     'name': os.path.basename(file_name),
                     'dir': os.path.dirname(file_name)
                 })
             confirm_overwrite.set_markup(message)
             confirm_overwrite.add_button(gtk.STOCK_CANCEL,
                                          gtk.RESPONSE_CANCEL)
             confirm_overwrite.add_button(_('Replace'), gtk.RESPONSE_OK)
             if confirm_overwrite.run() != gtk.RESPONSE_OK:
                 file_name = None
             confirm_overwrite.destroy()
         save_dialog.destroy()
         return file_name
     save_dialog.destroy()
     return None
Exemplo n.º 2
0
 def openProject(self, clear_current = True):
     open_dialog = FileDialog('open', file_filters = [(_('OCRFeeder Projects'), [], ['*.ocrf'])])
     response = open_dialog.run()
     project_file = None
     if response == gtk.RESPONSE_OK:
         project_file = open_dialog.get_filename()
         project_loader = ProjectLoader(project_file)
         pages = project_loader.loadConfiguration()
         if pages and clear_current:
             self.clear()
         for page in pages:
             image_reviewer = self.addImageFromPath(page.image_path)
             image_reviewer.updatePageData(page)
     open_dialog.destroy()
     return project_file
Exemplo n.º 3
0
 def openProject(self, clear_current = True):
     open_dialog = FileDialog('open', file_filters = [(_('OCRFeeder Projects'), [], ['*.ocrf'])])
     response = open_dialog.run()
     project_file = None
     if response == gtk.RESPONSE_OK:
         project_file = open_dialog.get_filename()
         project_loader = ProjectLoader(project_file)
         pages = project_loader.loadConfiguration()
         if pages and clear_current:
             self.clear()
         for index in range(0, len(pages)):
             page = pages[index]
             image_reviewer = self.__addImage(page.image_path,
                                              select_image = index == 0)
             image_reviewer.updatePageData(page)
     open_dialog.destroy()
     return project_file
Exemplo n.º 4
0
 def __askForFileName(self, extension = ''):
     save_dialog = FileDialog(self.main_window, 'save')
     response = save_dialog.run()
     if response == Gtk.ResponseType.OK:
         file_name = save_dialog.get_filename()
         if extension:
             if not file_name.endswith(extension):
                 file_name += extension
         if os.path.isfile(file_name):
             confirm_overwrite = Gtk.MessageDialog(message_type = Gtk.MessageType.QUESTION)
             message = _('<b>A file named "%(name)s" already exists. Do you want '
                         'to replace it?</b>\n\nThe file exists in "%(dir)s". '
                         'Replacing it will overwrite its contents.') % {
                          'name': os.path.basename(file_name),
                          'dir': os.path.dirname(file_name)}
             confirm_overwrite.set_markup(message)
             confirm_overwrite.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
             confirm_overwrite.add_button(_('Replace'), Gtk.ResponseType.OK)
             if confirm_overwrite.run() != Gtk.ResponseType.OK:
                 file_name = None
             confirm_overwrite.destroy()
         save_dialog.destroy()
         return file_name
     save_dialog.destroy()
     return None
Exemplo n.º 5
0
 def openProject(self, clear_current = True):
     open_dialog = FileDialog(self.main_window, 'open',
                              file_filters = [(_('OCRFeeder Projects'), [], ['*.ocrf'])])
     response = open_dialog.run()
     project_file = None
     if response == Gtk.ResponseType.OK:
         project_file = open_dialog.get_filename()
         project_loader = ProjectLoader(project_file)
         pages = project_loader.loadConfiguration()
         if pages and clear_current:
             self.clear()
         for index in range(0, len(pages)):
             page = pages[index]
             self.__addImage(page.image_path,
                             select_image = index == 0,
                             page_data = page)
     open_dialog.destroy()
     return project_file
Exemplo n.º 6
0
 def openProject(self, clear_current=True):
     open_dialog = FileDialog('open',
                              file_filters=[(_('OCRFeeder Projects'), [],
                                             ['*.ocrf'])])
     response = open_dialog.run()
     project_file = None
     if response == gtk.RESPONSE_OK:
         project_file = open_dialog.get_filename()
         project_loader = ProjectLoader(project_file)
         pages = project_loader.loadConfiguration()
         if pages and clear_current:
             self.clear()
         for page in pages:
             image_reviewer = self.addImageFromPath(page.image_path)
             image_reviewer.updatePageData(page)
     open_dialog.destroy()
     return project_file
Exemplo n.º 7
0
 def openProject(self, clear_current = True):
     open_dialog = FileDialog(self.main_window, 'open',
                              file_filters = [(_('OCRFeeder Projects'), [], ['*.ocrf'])])
     response = open_dialog.run()
     project_file = None
     if response == Gtk.ResponseType.OK:
         project_file = open_dialog.get_filename()
         project_loader = ProjectLoader(project_file)
         pages = project_loader.loadConfiguration()
         if pages and clear_current:
             self.clear()
         for index in range(0, len(pages)):
             page = pages[index]
             self.__addImage(page.image_path,
                             select_image = index == 0,
                             page_data = page)
     open_dialog.destroy()
     return project_file
Exemplo n.º 8
0
 def openProject(self, clear_current=True):
     open_dialog = FileDialog('open',
                              file_filters=[(_('OCRFeeder Projects'), [],
                                             ['*.ocrf'])])
     response = open_dialog.run()
     project_file = None
     if response == gtk.RESPONSE_OK:
         project_file = open_dialog.get_filename()
         project_loader = ProjectLoader(project_file)
         pages = project_loader.loadConfiguration()
         if pages and clear_current:
             self.clear()
         for index in range(0, len(pages)):
             page = pages[index]
             self.__addImage(page.image_path, select_image=index == 0)
             image_reviewer = self.__getCurrentReviewer()
             image_reviewer.updatePageData(page)
     open_dialog.destroy()
     return project_file