commit 135f208cf4a53c34a0b53ad62bd784f5ceb748b6
parent 9ae12c43e410abada7deeb6d4cdd1587243c8030
Author: ThomasV <thomasv@gitorious>
Date: Sat, 23 Feb 2013 21:01:19 +0100
method to run custom script
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/qt_console.py b/lib/qt_console.py
@@ -22,6 +22,14 @@ class Console(QtGui.QPlainTextEdit):
self.document().setDefaultFont(QtGui.QFont("monospace", 10, QtGui.QFont.Normal))
self.showMessage(startup_message)
+ self.updateNamespace({'run':self.run_script})
+
+ def run_script(self, filename):
+ with open(filename) as f:
+ script = f.read()
+ result = eval(script, self.namespace, self.namespace)
+
+
def updateNamespace(self, namespace):
self.namespace.update(namespace)