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
 
@@ -29,12 +29,13 @@ from light9.curvecalc import curveview
 
from light9.curvecalc.musicaccess import Music, currentlyPlayingSong
 
from light9.wavelength import wavelength
 
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()
 
    graph = Graph() # a copy, since we're going to add subs into it
 
    for s in graphOrig:
 
        graph.add(s)
 
@@ -108,12 +109,15 @@ class Main(object):
 
    def onQuit(self, *args):
 
        reactor.crash()
 
        # there's a hang after this, maybe in sem_wait in two
 
        # 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")
 

	
 
    def onSeeTimeUntilEnd(self, item):
 
        dispatcher.send("see time until end")
 

	
buildout.cfg
Show inline comments
 
@@ -4,13 +4,14 @@ bin-directory = bin
 
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
 
       Louie==1.1
 

	
 
python = python
light9/curvecalc/curvecalc.glade
Show inline comments
 
@@ -246,12 +246,39 @@
 
                      </object>
 
                    </child>
 
                  </object>
 
                </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>
 
            <property name="fill">True</property>
 
            <property name="position">0</property>
 
          </packing>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -598,12 +598,13 @@ class CurveRow(object):
 
    """
 
    one of the repeating curve rows (including widgets on the left)
 

	
 
    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)
 

	
 
        cols = gtk.HBox()
 
        self.box.add(cols)
 
        
 
@@ -729,14 +730,16 @@ class Curvesetview(object):
 
    def add_curve(self, name, slider=None, knobEnabled=False):
 
        curve = self.curveset.curves[name]
 
        f = CurveRow(name, curve, slider, knobEnabled, self.zoomControl)
 
        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
 
        themselves until this is called once (and then they're normal)"""
 
        
 
        for cr in self.allCurveRows:
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)