[dots/remove-assistant: 15/38] Initial table editor



commit 365f46ed823a5a8099d3640278fe39e2f6c50a3c
Author: Fernando Herrera <fherrera onirica com>
Date:   Fri Jul 9 02:10:59 2010 +0200

    Initial table editor

 dots/table_editor.py |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/dots/table_editor.py b/dots/table_editor.py
new file mode 100755
index 0000000..cd50a7d
--- /dev/null
+++ b/dots/table_editor.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# Dots - A braille translation program.
+#
+# Copyright (C) 2010 Consorcio Fernando de los Rios
+#               Author: Fernando Herrera <fherrera onirica com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import os
+from sys import exit
+import host_settings
+
+
+filename = "/opt/gnome/share/liblouis/tables/Es-Es-g1.utb"
+lines = open(filename, 'r').readlines()
+
+entries = []
+for line in lines:
+	line = line.lstrip(" ")
+	line = line.replace("\t", " ")
+	if line == '' or line[0] == '#' or line[0] == '<' or line[0] == '\n':
+		continue
+	elements = line.split(" ")
+	entry = {}
+	entry['opcode'] = elements[0]
+	i = 1
+	comment = False
+	for element in elements[1:]:
+		element = element.rstrip(" \t\n")
+		# FIXME: Can be an element 3 a legitimate # (ie: not a comment)?
+		if (element == " " or element == "") or (element == "#" and i >= 3):
+			entry['comment'] = ' '.join(elements[i+1:])
+			break
+		entry['element' + str(i)] = element
+		i = i + 1
+	entries.append (entry)
+
+for e in entries:
+	print "op=" + e['opcode']
+	print "\telement1=" + e['element1']
+	if "element2" in e:
+		print "\telement2=" + e['element2']
+	if "element3" in e:
+		print "\telement3=" + e['element3']
+	if "comment" in e:
+		print "\tcomment=" + e['comment']
+
+
+		
+import gtk
+
+window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+window.set_title("Basic TreeView Example")
+window.set_size_request(600, 600)
+liststore = gtk.ListStore(str, str, str, str, str)
+for e in entries:
+	iter = liststore.append ([e['opcode'], e['element1'], None, None, None])
+	if "element2" in e:
+		liststore.set_value(iter, 2, e['element2'])
+	if "element3" in e:
+		liststore.set_value(iter, 3, e['element3'])
+	if "comment" in e:
+		liststore.set_value(iter, 4, e['comment'])
+
+treeview = gtk.TreeView(liststore)
+for i in range(4):
+	tvcolumn = gtk.TreeViewColumn('Column ' + str(i))
+	treeview.append_column(tvcolumn)
+	cell = gtk.CellRendererText()
+	tvcolumn.pack_start(cell, True)
+	tvcolumn.add_attribute(cell, 'text', i)
+
+window.add(treeview)
+window.show_all()
+gtk.main()
+
+	
+	
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]