diff --git a/src/plugins/eval.glade b/src/plugins/eval.glade index 34b3dd890..e03d0e3ad 100644 --- a/src/plugins/eval.glade +++ b/src/plugins/eval.glade @@ -47,7 +47,7 @@ 6 True - 4 + 6 2 False 6 @@ -171,6 +171,66 @@ + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 2 + 5 + 6 + fill + + + + + + True + <b>Error Window</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 2 + 4 + 5 + fill + + + 0 @@ -203,7 +263,7 @@ True True True - gtk-apply + gtk-execute True GTK_RELIEF_NORMAL diff --git a/src/plugins/eval.py b/src/plugins/eval.py index 116b6c95b..cac971a49 100644 --- a/src/plugins/eval.py +++ b/src/plugins/eval.py @@ -22,10 +22,14 @@ Provides a python evaluation window """ import os +import cStringIO +import sys + import gtk import gtk.glade -from intl import gettext as _ +import Utils + class EvalWindow: @@ -34,9 +38,9 @@ class EvalWindow: self.glade = gtk.glade.XML(glade_file,"top") self.top = self.glade.get_widget("top") - self.display = self.glade.get_widget("display") - self.eval = self.glade.get_widget("eval") - self.ebuf = self.eval.get_buffer() + self.dbuf = self.glade.get_widget("display").get_buffer() + self.ebuf = self.glade.get_widget("eval").get_buffer() + self.error = self.glade.get_widget("error").get_buffer() self.glade.signal_autoconnect({ "on_apply_clicked" : self.apply_clicked, @@ -44,13 +48,27 @@ class EvalWindow: "on_clear_clicked" : self.clear_clicked, }) + Utils.set_titles(self.top,self.glade.get_widget('title'), + "Python Evaluation Window") + def apply_clicked(self,obj): text = self.ebuf.get_text(self.ebuf.get_start_iter(), self.ebuf.get_end_iter(),gtk.FALSE) + + outtext = cStringIO.StringIO() + errtext = cStringIO.StringIO() + sys.stdout = outtext + sys.stderr = errtext exec(text) + self.dbuf.set_text(outtext.getvalue()) + self.error.set_text(errtext.getvalue()) + sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ def clear_clicked(self,obj): - pass + self.dbuf.set_text("") + self.ebuf.set_text("") + self.error.set_text("") def close_clicked(self,obj): self.top.destroy() @@ -68,8 +86,8 @@ def runtool(database,person,callback): register_tool( runtool, - _("Python evaluation window"), - category=_("Debug"), - description=_("Provides a window that can evaluate python code") + "Python evaluation window", + category="Debug", + description="Provides a window that can evaluate python code" )