Ejemplo n.º 1
0
	def create_bookmark(self,*data):
		try:
			self.save_file_name
		except:
			dlg = dialog.Dialog(_("Warning!"),(_("Close!"), dialog.Dialog.BUTTON_ID_2))
			label = widget.Label(_("File must be saved inorder to bookmark the text!"))
			dlg.add_widget(label)
			dlg.show_all()
			response = dlg.run()
			dlg.destroy()
			return
			
		entry_sentence = widget.Entry()
		text = self.get_current_line_text()
		entry_sentence.set_text(text)		
		dlg = dialog.Dialog(_("Create new Bookmark"),(_("Bookmark"), dialog.Dialog.BUTTON_ID_1,_("Close!"), dialog.Dialog.BUTTON_ID_2))
		dlg.add_widget_with_label(entry_sentence,_("Name : "))
		entry_sentence.grab_focus()
		dlg.show_all()
		response = dlg.run()
		
		if response == dialog.Dialog.BUTTON_ID_1:
			# Note that this ### string will be deleted automatically 
			# Because it's considered as line number
			sentence = entry_sentence.get_text()
			# Note that this mark can't be used directly
			# Because it will always hold cursor position
			mark = self.get_cursor_mark()
			line_number = self.get_line_number_of_mark(mark)
			real_mark = self.get_mark_at_line(line_number)
			self.bookmark_list.append((sentence,real_mark))
			self.save_bookmark_table("None")
			dlg.destroy()
		else:
			dlg.destroy()		
Ejemplo n.º 2
0
	def button_add_image_box_pair_clicked(self,*data):
		file_chooser = FileChooserDialog(_("Select images to import"),
				FileChooserDialog.OPEN,["tif"],
				  macros.home_dir)
		file_chooser.set_current_folder(macros.home_dir)
		file_chooser.set_select_multiple(True)
		response = file_chooser.run()
		if response == FileChooserDialog.ACCEPT:
			image_list = file_chooser.get_filenames()
			file_chooser.destroy()
			no_box_file_image_list = []
			no_font_desc_file_image_list = []
			for item in image_list:
				self.icon_view_image_list.add_item(item);
				if (not os.path.isfile(".".join(item.split(".")[:-1])+".box")):
					no_box_file_image_list.append(item)
				if (not os.path.isfile(item+".font_desc")):
					no_font_desc_file_image_list.append(item)

			if (no_box_file_image_list != []):
				dlg = dialog.Dialog(_("No curresponding box files found!"),
				(_("No"), dialog.Dialog.BUTTON_ID_2,_("Yes"), dialog.Dialog.BUTTON_ID_1))
				label = widget.Label(_("Do you want to auto annotate box file with existing language ?\nThis may take awhile!"))
				dlg.add_widget(label)
				label.show()
				response = dlg.run()
				if (response == dialog.Dialog.BUTTON_ID_1):
					dlg.destroy()
					self.make_box_file_for_images(no_box_file_image_list)
				dlg.destroy()

			if (no_font_desc_file_image_list != []):
				dlg = dialog.Dialog(_("No curresponding font_desc files found!"),
				(_("No"), dialog.Dialog.BUTTON_ID_2,_("Yes"), dialog.Dialog.BUTTON_ID_1))
				label = widget.Label(_("Do you want to fill it with following font ?"))
				fontbox = FontBox()
				fontbox.set_font("Sans 0 0 0 0 0")
				dlg.add_widget(label)
				dlg.add_widget(fontbox)
				label.show()
				response = dlg.run()
				if (response == dialog.Dialog.BUTTON_ID_1):
					font = fontbox.get_font()
					dlg.destroy()
					for image_file in no_font_desc_file_image_list:
						f = open(image_file+".font_desc","w")
						f.write(font)
						f.close()
				dlg.destroy()
		else:
			file_chooser.destroy()
Ejemplo n.º 3
0
def read_text_from_file(filename, enc='utf8'):
    try:
        text = open(filename, encoding=enc).read()
        return text
    except UnicodeDecodeError:
        list = sorted(aliases.keys())
        combobox = widget.ComboBox()
        for item in macros.major_character_encodings_list:
            if (item in list):
                combobox.add_item(item)
        for item in list:
            combobox.add_item(item)
        combobox.set_active(0)

        dlg = dialog.Dialog(
            _("{} Decode error Select Other Character Encoding".format(enc)),
            (_("Select"), dialog.Dialog.BUTTON_ID_1))
        dlg.add_widget_with_label(combobox, _("Character Encoding : "))
        combobox.grab_focus()
        dlg.show_all()
        response = dlg.run()

        if response == dialog.Dialog.BUTTON_ID_1:
            index = combobox.get_active()
            dlg.destroy()
            text = read_text_from_file(filename, enc=list[index])
            return text
        else:
            dlg.destroy()
            return ""
Ejemplo n.º 4
0
 def find_previous(*data):
     word = entry_word.get_text()
     if (not self.is_cursor_at_start()):
         if (self.move_backward_to_word(word)):
             statusbar_context.set_text(self.get_context_text())
         else:
             dialog.Dialog(_("No match found")).run()
Ejemplo n.º 5
0
    def audio_converter(self, data=None):
        if (self.has_selection()):
            text = self.get_selected_text()
        else:
            text = self.get_text()

        dialog_ac = dialog.Dialog(_("Audio converter "),
                                  (_("Convert"), dialog.Dialog.BUTTON_ID_1,
                                   _("Close!"), dialog.Dialog.BUTTON_ID_2))
        grid = containers.Grid()

        spinbutton_speed = widget.SpinButton(50, 0, 100, 1, 5, 0)
        label_speed = widget.Label(_("Speed : "))
        label_speed.set_mnemonic_widget(spinbutton_speed)

        spinbutton_volume = widget.SpinButton(100, 0, 100, 1, 5, 0)
        label_volume = widget.Label(_("Volume : "))
        label_volume.set_mnemonic_widget(spinbutton_volume)

        spinbutton_pitch = widget.SpinButton(50, 0, 100, 1, 5, 0)
        label_pitch = widget.Label(_("Pitch : "))
        label_pitch.set_mnemonic_widget(spinbutton_pitch)

        spinbutton_split = widget.SpinButton(5, 0, 100, 1, 5, 0)
        label_split_time = widget.Label(_("Split Time : "))
        label_split_time.set_mnemonic_widget(spinbutton_split)

        combobox = widget.ComboBox()
        for item in text_to_audio_converter.list_voices():
            combobox.append_text(item)
        label_voice = widget.Label(_("Voice : "))
        label_voice.set_mnemonic_widget(combobox)

        grid.add_widgets([(label_speed, 1, 1), (spinbutton_speed, 1, 1),
                          containers.Grid.NEW_ROW, (label_volume, 1, 1),
                          (spinbutton_volume, 1, 1), containers.Grid.NEW_ROW,
                          (label_pitch, 1, 1), (spinbutton_pitch, 1, 1),
                          containers.Grid.NEW_ROW, (label_split_time, 1, 1),
                          (spinbutton_split, 1, 1), containers.Grid.NEW_ROW,
                          (label_voice, 1, 1), (combobox, 1, 1)])
        dialog_ac.add_widget(grid)
        grid.show_all()

        if (dialog_ac.run() == dialog.Dialog.BUTTON_ID_1):
            speed = spinbutton_speed.get_value()
            pitch = spinbutton_pitch.get_value()
            volume = spinbutton_volume.get_value()
            split = spinbutton_split.get_value()
            voice = combobox.get_active_text()
            save_file = file_chooser.FileChooserDialog(
                _("Select the file to open"),
                file_chooser.FileChooserDialog.SAVE, ["wav"], macros.home_dir)
            response = save_file.run()
            if response == file_chooser.FileChooserDialog.ACCEPT:
                converter = text_to_audio_converter(text, volume, voice, split,
                                                    pitch, speed)
                converter.record_to_wave(save_file.get_filename())
            save_file.destroy()
        dialog_ac.destroy()
Ejemplo n.º 6
0
	def place_traineddata(self,source,language):
		if (os.path.isfile(self.tessdata_dir+"/"+language+".traineddata")):
			dlg = dialog.Dialog(language+_(" Alrady exist! Please edit name to avoid replacing"),
			(_("Place it"), dialog.Dialog.BUTTON_ID_1))

			entry = widget.Entry()
			dlg.add_widget_with_label(entry,_("File Name : "))
			entry.set_text(language)
			response = dlg.run()
			language = entry.get_text()
			dlg.destroy()
		command = "cp {0} {1}/{2}.traineddata".format(source,self.tessdata_dir,language)
		self.run_command_in_super_user_mode(command,self.tessdata_dir)
		self.update_language_list()
Ejemplo n.º 7
0
	def entry_activated(self,*data):
		text = self.entry.get_text()
		if(not self.textview.move_forward_to_word(text)):
			dlg = dialog.Dialog(_("Not found!"),(_("Yes"),
			dialog.Dialog.BUTTON_ID_1,_("No"), dialog.Dialog.BUTTON_ID_2))
			label = widget.Label(_("The word '{0}' not found! Search from start ?".format(text)))
			dlg.add_widget(label)
			label.show()
			response = dlg.run()
			if response == dialog.Dialog.BUTTON_ID_1:
				self.textview.move_cursor_to_line(1)
				dlg.destroy()
				self.entry_activated()
			dlg.destroy()
Ejemplo n.º 8
0
		def add_clicked(*data):
			entry_match = widget.Entry()
			entry_replace = widget.Entry()
			dlg = dialog.Dialog(_("Give match and replace"),(_("Ok"), dialog.Dialog.BUTTON_ID_1,_("Close!"), dialog.Dialog.BUTTON_ID_2))
			dlg.add_widget_with_label(entry_match,_("Match : "))
			dlg.add_widget_with_label(entry_replace,_("Replace : "))
			entry_match.grab_focus()
			dlg.show_all()
			response = dlg.run()
			if (response == dialog.Dialog.BUTTON_ID_1):
				treeview.append((entry_match.get_text(),entry_replace.get_text()))
				self.text_cleaner_list = treeview.get_list()
				self.save_text_cleaner_list_to_file(macros.local_text_cleaner_list_file);
			dlg.destroy()
Ejemplo n.º 9
0
	def button_ambiguous_add_clicked(self,*data):
		dlg = dialog.Dialog(_("Add new ambiguous"),
		(_("Close"), dialog.Dialog.BUTTON_ID_1,_("Add"), dialog.Dialog.BUTTON_ID_2))
		entry_match = widget.Entry()
		entry_replace = widget.Entry()
		combobox_mandatory = widget.ComboBox()
		combobox_mandatory.add_item(_("No"))
		combobox_mandatory.add_item(_("Yes"))
		combobox_mandatory.set_active(0)
		dlg.add_widget_with_label(entry_match,_("Match    "))
		dlg.add_widget_with_label(entry_replace,_("Replace  "))
		dlg.add_widget_with_label(combobox_mandatory,_("Mandatory"))
		response = dlg.run()
		if(response == dialog.Dialog.BUTTON_ID_2):
			self.treeview_ambiguous.append((entry_match.get_text(),
			entry_replace.get_text(),combobox_mandatory.get_active()))
		dlg.destroy()
Ejemplo n.º 10
0
	def go_to_line(self,*data):
		current_line = self.get_cursor_line_number()
		maximum_line = self.get_line_count()		
		spinbutton_line = widget.SpinButton(current_line,0,maximum_line,1,5,0)
		
		dlg = dialog.Dialog(_("Go to line"),(_("Go"), dialog.Dialog.BUTTON_ID_1,_("Close!"), dialog.Dialog.BUTTON_ID_2))
		#spinbutton_line.connect("activate",lambda x : dialog.response(Gtk.ResponseType.ACCEPT))
		dlg.add_widget_with_label(spinbutton_line,_("Line Number : "))
		spinbutton_line.grab_focus()
		dlg.show_all()
		response = dlg.run()
		
		if response == dialog.Dialog.BUTTON_ID_1:
			to = spinbutton_line.get_value()
			self.move_cursor_to_line(to)
			self.highlights_cursor_line()
			dlg.destroy()
		else:
			dlg.destroy()
Ejemplo n.º 11
0
 def new(self, *data):
     if (self.get_modified() == True):
         dlg = dialog.Dialog(_("Start new without saving ?"),
                             ("Cancel", dialog.Dialog.BUTTON_ID_1,
                              _("Start-New!"), dialog.Dialog.BUTTON_ID_2))
         label = widget.Label(_("Start new without saving ?"))
         dlg.add_widget(label)
         label.show()
         response = dlg.run()
         dlg.destroy()
         if response == dialog.Dialog.BUTTON_ID_1:
             self.grab_focus()
             return 0
         else:
             self.delete_all_text()
             self.grab_focus()
             return 1
     else:
         self.delete_all_text()
         return 1
Ejemplo n.º 12
0
	def run_command_in_super_user_mode(self, command, directory):
		if(os.access(directory, os.W_OK)):
			os.system(command);
		else:
			if ("/bin/pkexec" in subprocess.getoutput("whereis pkexec")):
				os.system("pkexec "+command);
			elif ("/bin/gksudo" in subprocess.getoutput("whereis gksudo")):
				os.system("gksudo "+command);
			elif ("/bin/kdesudo" in subprocess.getoutput("whereis kdesudo")):
				os.system("kdesudo "+command);
			elif ("/bin/gksu" in subprocess.getoutput("whereis gksu")):
				os.system("gksu "+command);
			else:
				dlg = dialog.Dialog(_("Error : running command failed"),
				(_("Ok"), dialog.Dialog.BUTTON_ID_1))
				label = widget.Label(_("Can't run command : {0}\n Please make sure you have write access to {1}".format(command,directory)))
				dlg.add_widget(label)
				label.show()
				response = dlg.run()
				dlg.destroy()
Ejemplo n.º 13
0
	def button_remove_image_box_pair_clicked(self,*data):
		dlg = dialog.Dialog(_("Delete file too ?"),
		(_("No"), dialog.Dialog.BUTTON_ID_2,_("Yes"), dialog.Dialog.BUTTON_ID_1,_("Close"), dialog.Dialog.BUTTON_ID_3))
		label = widget.Label(_("Do you want to delete files(image,box,font_desc) too ?"))
		dlg.add_widget(label)
		label.show()
		response = dlg.run()
		if (response == dialog.Dialog.BUTTON_ID_1):
			image_list = self.icon_view_image_list.get_selected_item_names()
			for image in image_list:
				if (os.path.exists(image.replace(".tif",".box"))):
					os.remove(image.replace(".tif",".box"));
				if (os.path.exists(image+".font_desc")):
					os.remove(image+".font_desc");
			self.icon_view_image_list.remove_selected_items(True)

		elif (response == dialog.Dialog.BUTTON_ID_2):
			self.icon_view_image_list.remove_selected_items(False)

		dlg.destroy()
		self.box_editor.set_image("/usr/share/lios/lios.png")
Ejemplo n.º 14
0
	def train_image_box_pairs_clicked(self,*data):
		image_list = self.icon_view_image_list.get_selected_item_names()
		if (image_list == []):
			self.icon_view_image_list.select_all_items()
			image_list = self.icon_view_image_list.get_selected_item_names()
			if (image_list == []):
				return

		dlg = dialog.Dialog(_("Training images..."),
		(_("Close"), dialog.Dialog.BUTTON_ID_2,_("Train"), dialog.Dialog.BUTTON_ID_1))
		label = widget.Label(_("Images to be trained \n{0}\n \
		\nLanguage used : {1}\nOutput tessdata directory : {2}".format("\n".join(image_list),self.language,self.tessdata_dir)))
		label.set_ellipsize(True)
		dlg.add_widget(label)
		label.show()
		response = dlg.run()
		if (response != dialog.Dialog.BUTTON_ID_1):
			dlg.destroy()
			return
		dlg.destroy()


		self.output_terminal.run_command("cd /tmp/tesseract-train/")

		self.show_progress_bar("Training images...")
		tr_list = ""
		font_set = set()
		image_list_shell_type = []
		for img in image_list:
			image = self.get_shell_filename(img)
			image_list_shell_type.append(image)
			image_name_without_extension = ".".join(image.split(".")[:-1])
			tr_name =  ".".join((image.split("/")[-1]).split(".")[:-1])+".box.tr"

			self.output_terminal.run_command("tesseract --tessdata-dir {0} -l {1} {2} {3}.box nobatch box.train".format(self.tessdata_dir,self.language,image,image_name_without_extension));
			self.output_terminal.run_command("mv {0}.box.tr /tmp/tesseract-train/{1}".format(image_name_without_extension,tr_name))
			
			# getting each font desc
			try:
				font = open(image+".font_desc").read()
				font_set.add(font)
			except:
				pass

			tr_list = tr_list+tr_name+" "

		self.output_terminal.run_command("unicharset_extractor -D /tmp/tesseract-train/ "+(" ".join(image_list_shell_type).replace(".tif",".box")));

		# Saving all font desc
		f = open("/tmp/tesseract-train/font_properties","w")
		for item in font_set:
			f.write(item+"\n")
		f.close()

		self.output_terminal.run_command("shapeclustering -F font_properties -U unicharset "+tr_list);
		self.output_terminal.run_command("mftraining -F font_properties -U unicharset -O unicharset "+tr_list);
		self.output_terminal.run_command("cntraining "+tr_list);

		self.output_terminal.run_command("mv inttemp file.inttemp");
		self.output_terminal.run_command("mv normproto file.normproto");

		self.output_terminal.run_command("mv pffmtable file.pffmtable");
		self.output_terminal.run_command("mv shapetable file.shapetable");
		self.output_terminal.run_command("mv unicharset file.unicharset")

		dlg = dialog.Dialog(_("Combine with dictionarys too ?"),
		(_("No"), dialog.Dialog.BUTTON_ID_2,_("Yes"), dialog.Dialog.BUTTON_ID_1))
		label = widget.Label(_("Do you want to add dictionarys ? \
		\nDo it if only all characters used in dictionarys are going to be trained!"))
		dlg.add_widget(label)
		label.show()
		response = dlg.run()
		if (response != dialog.Dialog.BUTTON_ID_1):
			for item in DICT_LIST:
				if os.path.exists(item):
					os.remove(item)
		dlg.destroy()

		self.output_terminal.run_command("combine_tessdata file.");
		self.hide_progress_bar()
		self.place_traineddata("/tmp/tesseract-train/file.traineddata",self.language)
Ejemplo n.º 15
0
	def button_generate_image_clicked(self,*data):
		#Create image (using fonts)
		label_font_automatic = widget.Label(_("Font"));
		entry_font_automatic = widget.Entry()
		fontbutton_automatic = widget.FontButton();
		fontbutton_automatic.set_font("FreeMono")
		entry_font_automatic.set_editable(False)
		entry_font_automatic.set_text(fontbutton_automatic.get_font_name())
		button_choose_font_automatic = widget.Button(_("Choose-Font-File"));

		generate_and_train_text_view = text_view.TextView()
		scroll_box = containers.ScrollBox()
		scroll_box.set_size_request(-1,100);
		scroll_box.set_border_width(20);
		scroll_box.add(generate_and_train_text_view)

		def fontbutton_automatic_clicked(*data):
			fontname = fontbutton_automatic.get_font_name()
			entry_font_automatic.set_text(fontname)
			generate_and_train_text_view.set_font(fontname)
			spin_font_size.set_value(int(fontname.split()[-1]))

		def button_choose_font_automatic_clicked(*data):
			file_chooser = FileChooserDialog(_("Select font file"),
					FileChooserDialog.OPEN,"*",
					"/usr/share/fonts/")
			response = file_chooser.run()
			if response == FileChooserDialog.ACCEPT:
				font_file = file_chooser.get_filename()
				file_chooser.destroy()
				if (os.path.isfile(font_file)):
					entry_font_automatic.set_text(font_file)
					generate_and_train_text_view.set_font("FreeMono")
			else:
				file_chooser.destroy()

		def button_select_input_text_clicked(*data):
			file_chooser = FileChooserDialog(_("Select input file"),
					FileChooserDialog.OPEN,macros.supported_text_formats,macros.home_dir)
			response = file_chooser.run()
			if response == FileChooserDialog.ACCEPT:
				input_file = file_chooser.get_filename()
				file_chooser.destroy()
				if (os.path.isfile(input_file)):
					entry_input_text_automatic.set_text(input_file)
					generate_and_train_text_view.set_text(open(input_file).read())
			else:
				file_chooser.destroy()

		fontbutton_automatic.connect_function(fontbutton_automatic_clicked)		
		button_choose_font_automatic.connect_function(button_choose_font_automatic_clicked)

		label_font_size = widget.Label(_("Font Size"));
		spin_font_size = widget.SpinButton(10,8,96)

		label_select_input_text = widget.Label(_("Input Text File"));
		entry_input_text_automatic = widget.Entry()
		entry_input_text_automatic.set_editable(False)
		button_select_input_text = widget.Button(_("Choose"));
		button_select_input_text.connect_function(button_select_input_text_clicked)

		label_writing_mode = widget.Label(_("Writing Mode"));
		combobox_writing_mode = widget.ComboBox();
		combobox_writing_mode.add_item("horizontal")
		combobox_writing_mode.add_item("vertical")
		combobox_writing_mode.add_item("vertical-upright")
		combobox_writing_mode.set_active(0)

		label_writing_char_spacing_automatic = widget.Label(_("Inter-character space"));
		spinbutton_writing_char_spacing_automatic = widget.SpinButton(5,0,50)

		label_writing_resolution_automatic = widget.Label(_("Resolution"));
		spinbutton_writing_resolution_automatic = widget.SpinButton(300,100,1200)

		check_button_writing_degrade_image_automatic = widget.CheckButton(_("Degrade-image"))

		label_writing_exposure_level_automatic = widget.Label(_("Exposure-Level"));
		spinbutton_writing_exposure_level_automatic = widget.SpinButton(0,0,50)

		check_button_writing_ligature_mode_automatic = widget.CheckButton(_("Ligatur-Mode"))


		grid_manual_methord = containers.Grid()
		grid_manual_methord.add_widgets([(label_font_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(entry_font_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		(fontbutton_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		(button_choose_font_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(label_font_size,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(spin_font_size,3,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(label_select_input_text,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(entry_input_text_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		(button_select_input_text,2,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(scroll_box,4,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(label_writing_mode,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(combobox_writing_mode,3,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(label_writing_char_spacing_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(spinbutton_writing_char_spacing_automatic,3,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(label_writing_resolution_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(spinbutton_writing_resolution_automatic,3,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(label_writing_exposure_level_automatic,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND,containers.Grid.ALIGN_START),
		(spinbutton_writing_exposure_level_automatic,3,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(check_button_writing_degrade_image_automatic,2,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		(check_button_writing_ligature_mode_automatic,2,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND)])

		dlg = dialog.Dialog(_("Generate-Image"),(_("Generate"), dialog.Dialog.BUTTON_ID_1,_("Close!"), dialog.Dialog.BUTTON_ID_2))
		dlg.add_widget(grid_manual_methord)
		grid_manual_methord.show_all()

		response = dlg.run();
		if(response == dialog.Dialog.BUTTON_ID_1):
			self.show_progress_bar("Generating image...");
			#saving the text in textview to /tmp/tesseract-train/input_file.txt
			open("/tmp/tesseract-train/input_file.txt","w").write(generate_and_train_text_view.get_text())
			font = entry_font_automatic.get_text()
			font = font.split(" ")[0]
			fonts_dir = "/usr/share/fonts"
			if("/" in font):
				fonts_dir = "/".join(font.split("/")[:-1])
				font = font.split("/")[-1].split(".")[0]

			font_size = spin_font_size.get_value()
			input_file = entry_input_text_automatic.get_text()

			active = combobox_writing_mode.get_active()
			writing_mode = ["horizontal","vertical","vertical-upright"][active]

			char_space = spinbutton_writing_char_spacing_automatic.get_value()
			resolution = spinbutton_writing_resolution_automatic.get_value()
			exposure = spinbutton_writing_exposure_level_automatic.get_value()
			degrade = int(check_button_writing_degrade_image_automatic.get_active())
			ligature = int(check_button_writing_ligature_mode_automatic.get_active())
			self.generate_image_with_spec(font,font_size,writing_mode,char_space,resolution,exposure,degrade,ligature,fonts_dir)
		dlg.destroy()
Ejemplo n.º 16
0
    def open_configure_dialog(self, page=0):
        def change_engine(*data):
            index_engine = combobox_engine.get_active()
            combobox_language.clear()
            for item in self.available_ocr_engine_list[index_engine][1]:
                combobox_language.add_item(item)
            combobox_language.set_active(self.language)

        def change_speech_module(*data):
            index_engine = combobox_speech_module.get_active()
            combobox_speech_language.clear()
            test = speech.Speech()
            list = test.list_output_modules()
            test.set_output_module(list[index_engine])
            for item in test.list_voices():
                combobox_speech_language.add_item(item)
            combobox_speech_language.set_active(self.speech_language)

        def change_mode_of_rotation(*data):
            if (combobox_mode_of_rotation.get_active() == 2):
                combobox_angle.show()
                self.label_angle.show()
            else:
                combobox_angle.hide()
                self.label_angle.hide()

        self.require_scanner_refresh = False

        #Notebook
        notebook = containers.NoteBook()
        notebook.show_all()

        #GENERAL - PAGE #########
        label_font = widget.Label(_("Font"))
        fontbutton_font = widget.FontButton()
        fontbutton_font.set_font_name(self.font)
        label_font.set_mnemonic_widget(fontbutton_font)

        label_font_color = widget.Label(_("Font Color"))
        colorbutton_font = widget.ColorButton()
        colorbutton_font.set_color_from_string(self.font_color)
        label_font_color.set_mnemonic_widget(colorbutton_font)

        label_background_color = widget.Label(_("Background Color"))
        colorbutton_background = widget.ColorButton()
        colorbutton_background.set_color_from_string(self.background_color)
        label_background_color.set_mnemonic_widget(colorbutton_background)

        label_highlight_font = widget.Label(_("Highlight Font"))
        fontbutton_highlight_font = widget.FontButton()
        fontbutton_highlight_font.set_font_name(self.highlight_font)
        label_highlight_font.set_mnemonic_widget(fontbutton_highlight_font)

        label_highlight_color = widget.Label(_("Highlight Color"))
        colorbutton_highlight = widget.ColorButton()
        colorbutton_highlight.set_color_from_string(self.highlight_color)
        label_highlight_color.set_mnemonic_widget(colorbutton_highlight)

        label_highlight_background = widget.Label(_("Highlight Background"))
        colorbutton_highlight_background = widget.ColorButton()
        colorbutton_highlight_background.set_color_from_string(
            self.background_highlight_color)
        label_highlight_background.set_mnemonic_widget(
            colorbutton_highlight_background)

        label_speech_module = widget.Label(_("Speech-Module"))
        combobox_speech_module = widget.ComboBox()
        for item in speech.Speech().list_output_modules():
            combobox_speech_module.add_item(item)
        combobox_speech_module.connect_change_callback_function(
            change_speech_module)
        label_speech_module.set_mnemonic_widget(combobox_speech_module)

        label_speech_language = widget.Label(_("Speech-Language"))
        combobox_speech_language = widget.ComboBox()
        combobox_speech_module.set_active(self.speech_module)
        combobox_speech_language.set_active(self.speech_language)
        label_speech_language.set_mnemonic_widget(combobox_speech_language)

        label_speech_rate = widget.Label(_("Speech-Rate"))
        spin_speech_rate = widget.SpinButton(self.speech_rate, -100, 100, 1,
                                             10, 0)
        label_speech_rate.set_mnemonic_widget(spin_speech_rate)
        label_speech_volume = widget.Label(_("Speech-Volume"))
        spin_speech_volume = widget.SpinButton(self.speech_volume, -100, 100,
                                               1, 10, 0)
        label_speech_volume.set_mnemonic_widget(spin_speech_volume)
        label_speech_pitch = widget.Label(_("Speech-Pitch"))
        spin_speech_pitch = widget.SpinButton(self.speech_pitch, -100, 100, 1,
                                              10, 0)
        label_speech_pitch.set_mnemonic_widget(spin_speech_pitch)

        grid_general = containers.Grid()
        grid_general.add_widgets([
            (label_font, 1, 1), (fontbutton_font, 1, 1),
            containers.Grid.NEW_ROW, (label_font_color, 1, 1),
            (colorbutton_font, 1, 1), containers.Grid.NEW_ROW,
            (label_background_color, 1, 1), (colorbutton_background, 1, 1),
            containers.Grid.NEW_ROW, (label_highlight_font, 1, 1),
            (fontbutton_highlight_font, 1, 1), containers.Grid.NEW_ROW,
            (label_highlight_color, 1, 1), (colorbutton_highlight, 1,
                                            1), containers.Grid.NEW_ROW,
            (label_highlight_background, 1, 1),
            (colorbutton_highlight_background, 1, 1), containers.Grid.NEW_ROW,
            (label_speech_module, 1, 1), (combobox_speech_module, 1, 1),
            containers.Grid.NEW_ROW, (label_speech_language, 1, 1),
            (combobox_speech_language, 1, 1), containers.Grid.NEW_ROW,
            (label_speech_rate, 1, 1), (spin_speech_rate, 1, 1),
            containers.Grid.NEW_ROW, (label_speech_pitch, 1, 1),
            (spin_speech_pitch, 1, 1), containers.Grid.NEW_ROW,
            (label_speech_volume, 1, 1), (spin_speech_volume, 1, 1)
        ])
        notebook.add_page(_("General"), grid_general)
        grid_general.show_all()

        #RECOGNITION - PAGE ########
        #Engine
        label_engine = widget.Label(_("Engine"))
        combobox_engine = widget.ComboBox()
        combobox_engine.connect_change_callback_function(change_engine)
        label_engine.set_mnemonic_widget(combobox_engine)

        for item in self.available_ocr_engine_list:
            combobox_engine.add_item(item[0])

        #Language
        label_language = widget.Label(_("Language"))
        combobox_language = widget.ComboBox()
        label_language.set_mnemonic_widget(combobox_language)

        #setting current engine - This can't be done before creating language combobox
        combobox_engine.set_active(self.ocr_engine)
        combobox_language.set_active(self.language)

        #Run text cleaner
        checkbutton_run_text_cleaner = widget.CheckButton(
            _("Run Text Cleaner"))
        checkbutton_run_text_cleaner.set_active(self.run_text_cleaner)

        #insert_position
        label_insert_position = widget.Label(_("Insert Position"))
        combobox_insert_position = widget.ComboBox()
        combobox_insert_position.add_item(_("Start"))
        combobox_insert_position.add_item(_("Cursor"))
        combobox_insert_position.add_item(_("End"))
        combobox_insert_position.set_active(self.insert_position)
        label_insert_position.set_mnemonic_widget(combobox_insert_position)

        #Seperator
        seperator_1 = widget.Separator()

        #Mode of Rotation
        label_mode_of_rotation = widget.Label(_("Mode Of Rotation"))
        combobox_mode_of_rotation = widget.ComboBox()
        combobox_mode_of_rotation.add_item(_("Full Automatic"))
        combobox_mode_of_rotation.add_item(_("Partial Automatic"))
        combobox_mode_of_rotation.add_item(_("Manual"))
        combobox_mode_of_rotation.connect_change_callback_function(
            change_mode_of_rotation)
        label_mode_of_rotation.set_mnemonic_widget(combobox_mode_of_rotation)

        #Angle
        self.label_angle = widget.Label(_("Angle"))
        combobox_angle = widget.ComboBox()
        combobox_angle.add_item(_("00"))
        combobox_angle.add_item(_("90"))
        combobox_angle.add_item(_("180"))
        combobox_angle.add_item(_("270"))
        self.label_angle.set_mnemonic_widget(combobox_angle)

        #Seperator 2
        seperator_2 = widget.Separator()

        #Page-Numbering
        label_numbering_type = widget.Label(_("Page Numbering Type"))
        combobox_numbering_type = widget.ComboBox()
        combobox_numbering_type.add_item(_("Single Page"))
        combobox_numbering_type.add_item(_("Double Page"))
        combobox_numbering_type.set_active(self.page_numbering_type)
        label_numbering_type.set_mnemonic_widget(combobox_numbering_type)

        #Starting Page Number
        label_starting_page_number = widget.Label(_("Starting Page Number"))
        spin_starting_page_number = widget.SpinButton(0, 0, 100000, 1, 5, 0)
        spin_starting_page_number.set_value(self.starting_page_number)
        label_starting_page_number.set_mnemonic_widget(
            spin_starting_page_number)

        grid_recognition = containers.Grid()
        grid_recognition.add_widgets(
            [(label_engine, 1, 1), (combobox_engine, 1, 1),
             containers.Grid.NEW_ROW, (label_language, 1, 1),
             (combobox_language, 1, 1), containers.Grid.NEW_ROW,
             (checkbutton_run_text_cleaner, 1, 1), containers.Grid.NEW_ROW,
             (label_insert_position, 1, 1),
             (combobox_insert_position, 1, 1), containers.Grid.NEW_ROW,
             (seperator_1, 2, 1), containers.Grid.NEW_ROW,
             (label_mode_of_rotation, 1, 1), (combobox_mode_of_rotation, 1, 1),
             containers.Grid.NEW_ROW, (self.label_angle, 1, 1),
             (combobox_angle, 1, 1), containers.Grid.NEW_ROW,
             (seperator_2, 2, 1), containers.Grid.NEW_ROW,
             (label_numbering_type, 1, 1), (combobox_numbering_type, 1, 1),
             containers.Grid.NEW_ROW, (label_starting_page_number, 1, 1),
             (spin_starting_page_number, 1, 1)])
        notebook.add_page(_("Recognition"), grid_recognition)
        grid_recognition.show_all()

        #setting current mode of rotation - This can't be done before creating angle combobox
        #also it should be here because the show_all function of grid will make angle combobox show again
        combobox_mode_of_rotation.set_active(self.mode_of_rotation)
        combobox_angle.set_active(self.rotation_angle)

        #SCANNING - PAGE ##############
        label_resolution = widget.Label(_("Resolution"))
        spin_resolution = widget.SpinButton(300, 100, 1200, 1, 5, 0)
        spin_resolution.set_value(self.scan_resolution)
        label_resolution.set_mnemonic_widget(spin_resolution)

        label_brightness = widget.Label(_("Brightness"))
        spin_brightness = widget.SpinButton(50, 0, 100, 1, 5, 0)
        spin_brightness.set_value(self.scan_brightness)
        label_brightness.set_mnemonic_widget(spin_brightness)

        label_scan_area = widget.Label(_("Scan Area"))
        combobox_scan_area = widget.ComboBox()
        label_scan_area.set_mnemonic_widget(combobox_scan_area)
        combobox_scan_area.add_item(_("Full Scan Area"))
        combobox_scan_area.add_item(_("Three Quarters"))
        combobox_scan_area.add_item(_("Two Quarters"))
        combobox_scan_area.add_item(_("One Quarters"))
        combobox_scan_area.set_active(self.scan_area)

        label_scan_driver = widget.Label(_("Driver"))
        combobox_scan_driver = widget.ComboBox()
        label_scan_driver.set_mnemonic_widget(combobox_scan_driver)
        for item in self.available_scanner_drivers:
            combobox_scan_driver.add_item(item)
        combobox_scan_driver.set_active(self.scan_driver)

        sparator_3 = widget.Separator()

        label_number_of_pages_to_scan = widget.Label(
            _("Number of Pages to Scan"))
        spin_number_of_pages_to_scan = widget.SpinButton(10, 2, 100, 1, 5, 0)
        spin_number_of_pages_to_scan.set_value(self.number_of_pages_to_scan)
        label_number_of_pages_to_scan.set_mnemonic_widget(
            spin_number_of_pages_to_scan)

        label_time_bitween_repeted_scanning = widget.Label(
            _("Time Bitween Repeted Scanning"))
        spin_time_bitween_repeted_scanning = widget.SpinButton(
            0, 0, 30, 1, 5, 0)
        spin_time_bitween_repeted_scanning.set_value(
            self.time_between_repeated_scanning)
        label_time_bitween_repeted_scanning.set_mnemonic_widget(
            spin_time_bitween_repeted_scanning)

        sparator_4 = widget.Separator()

        checkbutton_scan_mode_switching = widget.CheckButton(
            _("Change to binary or lineart if possible"))
        checkbutton_scan_mode_switching.set_active(self.scanner_mode_switching)

        checkbutton_scanner_cache_calibration = widget.CheckButton(
            _("Cache Calibration"))
        checkbutton_scanner_cache_calibration.set_active(
            self.scanner_cache_calibration)

        grid_scanning = containers.Grid()
        grid_scanning.add_widgets([
            (label_resolution, 1, 1), (spin_resolution, 1, 1),
            containers.Grid.NEW_ROW, (label_brightness, 1, 1),
            (spin_brightness, 1, 1), containers.Grid.NEW_ROW,
            (label_scan_area, 1, 1), (combobox_scan_area, 1, 1),
            containers.Grid.NEW_ROW, (label_scan_driver, 1, 1),
            (combobox_scan_driver, 1, 1), containers.Grid.NEW_ROW,
            (sparator_3, 2, 1), containers.Grid.NEW_ROW,
            (label_number_of_pages_to_scan, 1, 1),
            (spin_number_of_pages_to_scan, 1, 1), containers.Grid.NEW_ROW,
            (label_time_bitween_repeted_scanning, 1, 1),
            (spin_time_bitween_repeted_scanning, 1, 1),
            containers.Grid.NEW_ROW, (sparator_4, 2,
                                      1), containers.Grid.NEW_ROW,
            (checkbutton_scan_mode_switching, 2, 1), containers.Grid.NEW_ROW,
            (checkbutton_scanner_cache_calibration, 2, 1)
        ])

        notebook.add_page(_("Scanning"), grid_scanning)
        grid_scanning.show_all()

        #Setting page
        notebook.set_current_page(page)

        dlg = dialog.Dialog(_("Lios Preferences"),
                            (_("Apply"), dialog.Dialog.BUTTON_ID_1, _("Close"),
                             dialog.Dialog.BUTTON_ID_2))
        dlg.add_widget(notebook)
        if (dlg.run() == True):
            self.font = fontbutton_font.get_font_name()
            self.font_color = colorbutton_font.get_color_as_string()
            self.background_color = colorbutton_background.get_color_as_string(
            )

            self.highlight_font = fontbutton_highlight_font.get_font_name()
            self.highlight_color = colorbutton_highlight.get_color_as_string()
            self.background_highlight_color = colorbutton_highlight_background.get_color_as_string(
            )

            self.ocr_engine = combobox_engine.get_active()
            self.language = combobox_language.get_active()
            self.speech_module = combobox_speech_module.get_active()
            self.speech_language = combobox_speech_language.get_active()
            self.speech_rate = spin_speech_rate.get_value()
            self.speech_pitch = spin_speech_pitch.get_value()
            self.speech_volume = spin_speech_volume.get_value()
            self.insert_position = combobox_insert_position.get_active()
            self.mode_of_rotation = combobox_mode_of_rotation.get_active()
            self.rotation_angle = combobox_angle.get_active()
            self.page_numbering_type = combobox_numbering_type.get_active()
            self.starting_page_number = spin_starting_page_number.get_value_as_int(
            )

            self.scan_resolution = spin_resolution.get_value_as_int()
            self.scan_brightness = spin_brightness.get_value_as_int()
            self.scan_area = combobox_scan_area.get_active()
            self.scan_driver = combobox_scan_driver.get_active()
            self.number_of_pages_to_scan = spin_number_of_pages_to_scan.get_value_as_int(
            )
            self.time_between_repeated_scanning = spin_time_bitween_repeted_scanning.get_value_as_int(
            )
            self.scanner_mode_switching = int(
                checkbutton_scan_mode_switching.get_active())
            self.run_text_cleaner = int(
                checkbutton_run_text_cleaner.get_active())
            self.scanner_cache_calibration = int(
                checkbutton_scanner_cache_calibration.get_active())

            dlg.destroy()
            return True
        dlg.destroy()
        return False
Ejemplo n.º 17
0
	def __init__(self,image_list=None):
		window.Window.__init__(self, title=_("Tesseract Trainer"))
		self.set_taskbar_icon(macros.logo_file)
		grid = containers.Grid()
		
		if( not ocr.ocr_engine_tesseract.OcrEngineTesseract.is_available()):
			label = widget.Label(_("Tesseract is not installed"))
			self.add(label)
			label.show()
			self.set_default_size(400,200)
			return

		if( not ocr.ocr_engine_tesseract.OcrEngineTesseract.is_training_executables_available()):
			label = widget.Label(_("""Tesseract training executable are not installed. 
Please make sure following exicutables are installed
\ncombine_tessdata, unicharset_extractor, shapeclustering, mftraining, cntraining and text2image.
\nIf you forget to build training tools then use 'make training' and 'sudo make training-install' to build it """))
			self.add(label)
			label.show()
			self.set_default_size(400,200)
			return

		if(not os.path.isdir("/tmp/tesseract-train/")):
			os.mkdir("/tmp/tesseract-train/")

		self.output_terminal = terminal.Terminal("")
		self.output_terminal.set_scrollback_lines(10000)
		scroll_box_output = containers.ScrollBox()
		scroll_box_output.add(self.output_terminal)
		self.output_terminal.connect_context_menu_button_callback(self.terminal_popup_context_menu)
		self.context_menu_terminal = menu.ContextMenu(
			[(_("Copy"),self.terminal_copy_clipboard),
			(_("Paste"),self.terminal_paste_clipboard)])

		#Notebook
		notebook = containers.NoteBook()
		notebook.show_all()
		
		paned_notebook_and_output_terminal = containers.Paned(containers.Paned.VERTICAL)
		paned_notebook_and_output_terminal.add(notebook)
		paned_notebook_and_output_terminal.add(scroll_box_output)
		

		# Train image-box pairs
		seperator_select_images = widget.Separator()
		
		self.icon_view_image_list = icon_view.IconView()
		self.icon_view_image_list.connect_on_selected_callback(self.on_iconview_item_selected)
		scroll_box_iconview = containers.ScrollBox()
		self.icon_view_image_list.set_vexpand(True)
		scroll_box_iconview.add(self.icon_view_image_list)
		
		for item in image_list:
			self.icon_view_image_list.add_item(item);
		self.icon_view_image_list.show()
		
		box_buttons = containers.Box(containers.Box.VERTICAL)

		button_add_image_box_pair = widget.Button("Add Image-Box pairs");
		button_add_image_box_pair.connect_function(self.button_add_image_box_pair_clicked);
		box_buttons.add(button_add_image_box_pair)

		button_generate_image = widget.Button("Generate-Image-Using-Fonts");
		button_generate_image.connect_function(self.button_generate_image_clicked);
		box_buttons.add(button_generate_image)

		button_remove_image_box_pair = widget.Button("Remove Image-Box pair");
		button_remove_image_box_pair.connect_function(self.button_remove_image_box_pair_clicked);
		box_buttons.add(button_remove_image_box_pair)

		button_annotate_image = widget.Button("Annotate(Detect boxes)");
		button_annotate_image.connect_function(self.button_annotate_image_clicked);
		box_buttons.add(button_annotate_image)

		button_re_annotate_image = widget.Button("Re-Annotate(Detect boxes)");
		button_re_annotate_image.connect_function(self.button_annotate_image_clicked);
		box_buttons.add(button_re_annotate_image)

		button_ocr_and_view = widget.Button("OCR & View Output");
		button_ocr_and_view.connect_function(self.button_ocr_and_view_clicked);
		box_buttons.add(button_ocr_and_view)

		button_train_image_box_pairs = widget.Button("Train Image-Box pairs");
		button_train_image_box_pairs.connect_function(self.train_image_box_pairs_clicked);

		self.box_editor = BoxEditor(self.on_image_view_box_list_updated)
		self.font_box = FontBox()
		self.font_box.connect_change_handler(self.font_changed)
		
		box_font_and_box = containers.Box(containers.Box.VERTICAL)
		box_font_and_box.add(self.font_box)
		box_font_and_box.add(self.box_editor)
		box_font_and_box.add(button_train_image_box_pairs)

		box_iconview_and_buttons = containers.Box(containers.Box.VERTICAL) 
		box_iconview_and_buttons.add(scroll_box_iconview)
		box_iconview_and_buttons.add(box_buttons)

		paned_iconview_and_image_view = containers.Paned(containers.Paned.HORIZONTAL)
		paned_iconview_and_image_view.add(box_iconview_and_buttons)
		paned_iconview_and_image_view.add(box_font_and_box)

		notebook.add_page(_("Train images-box"),paned_iconview_and_image_view);		


		#Ambiguous Editor
		self.treeview_ambiguous = tree_view.TreeView([("match",str,True),
		("Replacement",str,True),("Mandatory",int,True)],self.ambiguous_edited_callback)

		button_ambiguous_train = widget.Button(_("Train"));
		button_ambiguous_train.connect_function(self.button_ambiguous_train_clicked)

		button_ambiguous_add = widget.Button(_("Add"));
		button_ambiguous_add.connect_function(self.button_ambiguous_add_clicked)

		button_ambiguous_delete = widget.Button(_("Delete"));
		button_ambiguous_delete.connect_function(self.button_ambiguous_delete_clicked)

		button_ambiguous_delete_all = widget.Button(_("Delete-All"));
		button_ambiguous_delete_all.connect_function(self.button_ambiguous_delete_all_clicked)

		button_ambiguous_import = widget.Button(_("Import"));
		button_ambiguous_import.connect_function(self.button_ambiguous_import_clicked)

		button_ambiguous_export = widget.Button(_("Export"));
		button_ambiguous_export.connect_function(self.button_ambiguous_export_clicked)

		scrolled_ambiguous = containers.ScrollBox()
		scrolled_ambiguous.add(self.treeview_ambiguous)

		box_ambiguous_buttons = containers.Box(containers.Box.VERTICAL)
		box_ambiguous_buttons.add(button_ambiguous_add),
		box_ambiguous_buttons.add(button_ambiguous_delete)
		box_ambiguous_buttons.add(button_ambiguous_delete_all)
		box_ambiguous_buttons.add(button_ambiguous_import)
		box_ambiguous_buttons.add(button_ambiguous_export)
		box_ambiguous_buttons.set_homogeneous(True)

		self.combobox_ambiguous_write_format = widget.ComboBox()
		self.combobox_ambiguous_write_format.add_item("Write in V1")
		self.combobox_ambiguous_write_format.add_item("Write in V2")

		grid_set_ambiguous = containers.Grid()
		grid_set_ambiguous.add_widgets([
		(scrolled_ambiguous,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		(box_ambiguous_buttons,1,1,containers.Grid.NO_HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(self.combobox_ambiguous_write_format,2,1,containers.Grid.NO_HEXPAND,containers.Grid.NO_VEXPAND),
		containers.Grid.NEW_ROW,
		(button_ambiguous_train,2,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND)])

		notebook.add_page("Ambiguous",grid_set_ambiguous);


		#Dictionary Editor
		notebook_dicts = containers.NoteBook()
		self.dictionary_objects = []
		for item in DICT_LIST+[macros.home_dir+"/lios/user-words"]:
			dict_object = Dictionary(item)
			notebook_dicts.add_page(item.split("/")[-1],dict_object)
			self.dictionary_objects.append(dict_object)

		button_bind_dictionarys = widget.Button("Bind Dictionary's ")
		button_bind_dictionarys.connect_function(self.button_bind_dictionarys_clicked)

		grid_set_dictionary = containers.Grid()
		grid_set_dictionary.add_widgets([(notebook_dicts,1,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,
		(button_bind_dictionarys,2,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND)]);
		notebook.add_page(_("Dictionary's"),grid_set_dictionary);	

		label_language = widget.Label(_("Language "));
		self.combobox_language = widget.ComboBox();
		self.combobox_language.connect_change_callback_function(self.language_combobox_changed);

		label_tessdata_dir = widget.Label(_("Tessdata directory "));
		self.combobox_tessdata_dir = widget.ComboBox();
		self.combobox_tessdata_dir.connect_change_callback_function(self.tessdata_dir_combobox_changed);

		button_import_language = widget.Button(_("Import"))
		button_import_language.connect_function(self.button_import_language_clicked)
		button_export_language = widget.Button(_("Export"))
		button_export_language.connect_function(self.button_export_language_clicked)
		button_remove_language = widget.Button(_("Remove"))
		button_remove_language.connect_function(self.button_remove_language_clicked)

		self.progress_bar = widget.ProgressBar()
		self.progress_bar.set_show_text(True)
		
		button_close = widget.Button(_("Close"));
		button_close.connect_function(self.close_trainer);
		
		grid.add_widgets([(label_tessdata_dir,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		(self.combobox_tessdata_dir,4,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		containers.Grid.NEW_ROW,
		(label_language,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		(self.combobox_language,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		(button_import_language,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		(button_export_language,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		(button_remove_language,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND),
		containers.Grid.NEW_ROW,(paned_notebook_and_output_terminal,5,1,containers.Grid.HEXPAND,containers.Grid.VEXPAND),
		containers.Grid.NEW_ROW,(self.progress_bar,4,1,containers.Grid.NO_HEXPAND,containers.Grid.NO_VEXPAND),
		(button_close,1,1,containers.Grid.HEXPAND,containers.Grid.NO_VEXPAND)])
		
		
		self.add(grid)
		grid.show_all()
		self.maximize()

		dlg = dialog.Dialog(_("Search entire filesystem for tessdata ?"),
		(_("No"), dialog.Dialog.BUTTON_ID_2,_("Yes"), dialog.Dialog.BUTTON_ID_1))
		label = widget.Label(_("Do you want to search entire filesystem for tessdata ?\nThis may take awhile!"))
		dlg.add_widget(label)
		label.show()
		response = dlg.run()
		if (response == dialog.Dialog.BUTTON_ID_1):
			dir_list = ocr.ocr_engine_tesseract.OcrEngineTesseract.get_all_available_dirs()
		else:
			dir_list = ocr.ocr_engine_tesseract.OcrEngineTesseract.get_available_dirs()
		dlg.destroy()

		self.tessdata_dir_available_list = []
		for item in dir_list:
			self.combobox_tessdata_dir.add_item(item)
			self.tessdata_dir_available_list.append(item)
		self.combobox_tessdata_dir.set_active(0)
		self.box_editor.set_image("/usr/share/lios/lios.png")