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
 
@@ -23,24 +23,25 @@ import logging
 
log = logging.getLogger()
 

	
 
import run_local
 
from light9 import showconfig, prof
 
from light9.curvecalc.curve import Curveset
 
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)
 
    read_all_subs(graph)
 
    return graph
 

	
 
class Main(object):
 
    def __init__(self, graph, opts, song, curveset, subterms, music):
 
        self.graph, self.opts, self.song = graph, opts, song
 
@@ -102,24 +103,27 @@ class Main(object):
 
        dialog.hide()
 

	
 
    def refreshTheme(self):
 
        gtk.rc_reparse_all()
 
        reactor.callLater(1, self.refreshTheme)
 

	
 
    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")
 

	
 
    def onZoomAll(self, item):
 
        dispatcher.send("show all")
 

	
 
    def onPlayPause(self, item):
 
        # since the X coord in a curveview affects the handling, one
 
        # of them may be able to pick this up
buildout.cfg
Show inline comments
 
[buildout]
 
parts = external_libs 
 
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
 
interpreter = python
 
extra-paths = 
 

	
 
[python]
 
executable = /usr/bin/python2.7
 

	
light9/curvecalc/curvecalc.glade
Show inline comments
 
@@ -240,24 +240,51 @@
 
                      <object class="GtkMenuItem" id="menuitem6">
 
                        <property name="visible">True</property>
 
                        <property name="can_focus">False</property>
 
                        <property name="use_action_appearance">False</property>
 
                        <property name="label" translatable="yes">Delete (del)</property>
 
                        <property name="use_underline">True</property>
 
                      </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>
 
        </child>
 
        <child>
 
          <object class="GtkVPaned" id="paned1">
 
            <property name="height_request">600</property>
 
            <property name="visible">True</property>
 
            <property name="can_focus">True</property>
light9/curvecalc/curveview.py
Show inline comments
 
@@ -592,24 +592,25 @@ class Curveview(object):
 
        if not self.dragging_dots:
 
            return
 
        self.last_mouse_world = None
 
        self.dragging_dots = False
 

	
 
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)
 
        
 
        controls = gtk.Frame()
 
        controls.set_size_request(115, -1)
 
        controls.set_shadow_type(gtk.SHADOW_OUT)
 
        cols.pack_start(controls, expand=False)
 
        self.setupControls(controls, name, curve, slider)
 

	
 
@@ -723,22 +724,24 @@ class Curvesetview(object):
 
        self.entry.focus()
 

	
 
    def new_curve(self, event):
 
        self.curveset.new_curve(self.newcurvename.get())
 
        self.newcurvename.set('')
 
        
 
    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:
 
            cr.curveView.goLive()
 

	
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)