Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/GUI_Components/Compound_Widgets/Reading_View.py
diff options
context:
space:
mode:
Diffstat (limited to 'GUI_Components/Compound_Widgets/Reading_View.py')
-rw-r--r--GUI_Components/Compound_Widgets/Reading_View.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/GUI_Components/Compound_Widgets/Reading_View.py b/GUI_Components/Compound_Widgets/Reading_View.py
new file mode 100644
index 0000000..f044982
--- /dev/null
+++ b/GUI_Components/Compound_Widgets/Reading_View.py
@@ -0,0 +1,74 @@
+# Copyright (C) IBM Corporation 2008
+import pygtk
+pygtk.require('2.0')
+import gtk
+from GUI_Components.Compound_Widgets.Base_Widgets.Readonly_Textbox import Readonly_Textbox
+from Processing.IO_Manager import IO_Manager
+
+class Reading_View( gtk.VBox ):
+ """
+ Created by Jonathan Mace
+
+ This class wraps a Readonly_Textbox in a scrollable window, and adds
+ a combobox.
+ The combobox is populated, externally, with the names of
+ articles which can be selected.
+ If an article is selected in the combobox, the readonly_textbox will
+ be set to display the newly selected article.
+ The articles are loaded using IO_Manager
+ """
+
+ def __init__(self):
+ gtk.VBox.__init__(self)
+
+ self.articlemenu = gtk.combo_box_new_text()
+ self.articlemenu.connect("changed", self.source_selected, None)
+ self.pack_start(self.articlemenu, False, False, 1)
+ self.articlemenu.show()
+
+ self.articlewindow = gtk.ScrolledWindow()
+ self.articlewindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ self.pack_start(self.articlewindow)
+ self.articlewindow.show()
+
+ self.textbox = Readonly_Textbox()
+ self.articlewindow.add(self.textbox)
+ self.textbox.show()
+
+ def source_selected(self, combo, data):
+ title = combo.get_active_text()
+ if title == "Select a source article from this menu" or title == None:
+ return
+ if self.textbox.get_article() == None or self.textbox.get_article().article_title == title:
+ return
+ if combo.get_active != 0:
+ model = combo.get_model()
+ firstiter = model.get_iter_first()
+ firstvalue = model.get_value(firstiter, 0)
+ print firstvalue
+ if firstvalue == "Select a source article from this menu":
+ combo.remove_text(0)
+
+ if self.textbox.get_article() != None:
+ theme = "Wikipedia Articles"
+ try:
+ newarticle = IO_Manager().load_article(title, theme)
+ self.textbox.set_article(newarticle)
+ except Exception, e:
+ pass
+
+ def set_sentence_selection_mode(self):
+ self.textbox.set_mode(0)
+
+ def set_paragraph_selection_mode(self):
+ self.textbox.set_mode(1)
+
+ def set_section_selection_mode(self):
+ self.textbox.set_mode(2)
+
+ def set_full_edit_mode(self):
+ self.textbox.set_mode(3)
+
+ def clear_contents(self):
+ self.textbox.clear()
+ \ No newline at end of file