Changeset - 10ee0756a119
[Not reviewed]
default
0 4 1
Drew Perttula - 13 years ago 2012-06-10 09:45:56
drewp@bigasterisk.com
new python console
Ignore-this: e6f8fa24c730e3cf8ed76be3fc1dcd01
5 files changed with 71 insertions and 2 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -32,6 +32,7 @@ from light9.namespaces import L9
 
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 @@ class Main(object):
 
        # 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")
 

	
buildout.cfg
Show inline comments
 
@@ -7,7 +7,8 @@ download-cache = /tmp/
 

	
 
[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
light9/curvecalc/curvecalc.glade
Show inline comments
 
@@ -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>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -601,6 +601,7 @@ class CurveRow(object):
 
    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 @@ class Curvesetview(object):
 
        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
light9/gtkpyconsole.py
Show inline comments
 
new file 100644
 
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()
 

	
0 comments (0 inline, 0 general)