Handle stdout
svn: r1526
This commit is contained in:
parent
d5272fd396
commit
bca4da2b41
@ -47,7 +47,7 @@
|
||||
<widget class="GtkTable" id="table2">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_rows">6</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">6</property>
|
||||
@ -171,6 +171,66 @@
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTextView" id="error">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_NONE</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
<property name="pixels_above_lines">0</property>
|
||||
<property name="pixels_below_lines">0</property>
|
||||
<property name="pixels_inside_wrap">0</property>
|
||||
<property name="left_margin">0</property>
|
||||
<property name="right_margin">0</property>
|
||||
<property name="indent">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
<property name="x_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Error Window</b></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
@ -203,7 +263,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-apply</property>
|
||||
<property name="label">gtk-execute</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<signal name="clicked" handler="on_apply_clicked" last_modification_time="Sun, 11 May 2003 21:01:26 GMT"/>
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user