changeset 708:10ee0756a119

new python console Ignore-this: e6f8fa24c730e3cf8ed76be3fc1dcd01
author Drew Perttula <drewp@bigasterisk.com>
date Sun, 10 Jun 2012 09:45:56 +0000
parents c4a38a247b26
children 7a41504ed8fc
files bin/curvecalc buildout.cfg light9/curvecalc/curvecalc.glade light9/curvecalc/curveview.py light9/gtkpyconsole.py
diffstat 5 files changed, 71 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/bin/curvecalc	Sun Jun 10 08:54:17 2012 +0000
+++ b/bin/curvecalc	Sun Jun 10 09:45:56 2012 +0000
@@ -32,6 +32,7 @@
 from light9.curvecalc.subterm import read_all_subs, savekey, graphPathForSubterms
 from light9.curvecalc.subtermview import add_one_subterm
 from light9.curvecalc.output import Output
+from light9.gtkpyconsole import togglePyConsole
 
 def makeGraph():
     graphOrig = showconfig.getGraph()
@@ -111,6 +112,9 @@
         # threads. I don't know whose they are.
         os.kill(os.getpid(), signal.SIGKILL)
 
+    def onPythonConsole(self, item):
+        togglePyConsole(self, item, self.__dict__)
+        
     def onSeeCurrentTime(self, item):
         dispatcher.send("see time")
 
--- a/buildout.cfg	Sun Jun 10 08:54:17 2012 +0000
+++ b/buildout.cfg	Sun Jun 10 09:45:56 2012 +0000
@@ -7,7 +7,8 @@
 
 [external_libs]
 recipe = zc.recipe.egg
-eggs = web.py==0.36
+eggs = ipython==0.8.4
+       web.py==0.36
        cyclone==1.0-rc4
        rdflib==3.2.1
        restkit==4.1.2
--- a/light9/curvecalc/curvecalc.glade	Sun Jun 10 08:54:17 2012 +0000
+++ b/light9/curvecalc/curvecalc.glade	Sun Jun 10 09:45:56 2012 +0000
@@ -249,6 +249,33 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkMenuItem" id="menuitem16">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="use_action_appearance">False</property>
+                <property name="label" translatable="yes">Debug</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu7">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="ubuntu_local">True</property>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="checkmenuitem1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="label" translatable="yes">Python console</property>
+                        <property name="use_underline">True</property>
+                        <accelerator key="p" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
+                        <signal name="toggled" handler="onPythonConsole" swapped="no"/>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
--- a/light9/curvecalc/curveview.py	Sun Jun 10 08:54:17 2012 +0000
+++ b/light9/curvecalc/curveview.py	Sun Jun 10 09:45:56 2012 +0000
@@ -601,6 +601,7 @@
     please pack self.box
     """
     def __init__(self, name, curve, slider, knobEnabled, zoomControl):
+        self.name = name
         self.box = gtk.HandleBox()
         self.box.set_border_width(1)
 
@@ -732,8 +733,10 @@
         self.curvesVBox.pack_end(f.box)
         f.box.show_all()
         self.allCurveRows.add(f)
-        #f.curveView.goLive()
+        f.curveView.goLive()
 
+    def row(self, name):
+        return [r for r in self.allCurveRows if r.name == name][0]
 
     def goLive(self):
         """for startup performance, none of the curves redraw
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/light9/gtkpyconsole.py	Sun Jun 10 09:45:56 2012 +0000
@@ -0,0 +1,34 @@
+from lib.ipython_view import IPythonView
+import pango, gtk
+
+def togglePyConsole(self, item, user_ns):
+    """
+    toggles a toplevel window with an ipython console inside.
+
+    self is an object we can stick the pythonWindow attribute on
+
+    item is a checkedmenuitem
+
+    user_ns is a dict you want to appear as locals in the console
+    """
+    if item.get_active():
+        if not hasattr(self, 'pythonWindow'):
+            self.pythonWindow = gtk.Window()
+            S = gtk.ScrolledWindow()
+            S.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+            V = IPythonView(user_ns=user_ns)
+            V.modify_font(pango.FontDescription("luxi mono 8"))
+            V.set_wrap_mode(gtk.WRAP_CHAR)
+            S.add(V)
+            self.pythonWindow.add(S)
+            self.pythonWindow.show_all()
+            self.pythonWindow.set_size_request(750, 550)
+            self.pythonWindow.set_resizable(True)
+            def onDestroy(*args):
+                item.set_active(False)
+                del self.pythonWindow
+            self.pythonWindow.connect("destroy", onDestroy)
+    else:
+        if hasattr(self, 'pythonWindow'):
+            self.pythonWindow.destroy()
+