From d94593a3b2e6eae11e2545c7dc014e14ba5ca381 Mon Sep 17 00:00:00 2001 From: Victor Lazzarini Date: Wed, 06 Aug 2008 13:12:10 +0000 Subject: added new functionality to csndsugui --- (limited to 'playfile.activity/csndsugui.py') diff --git a/playfile.activity/csndsugui.py b/playfile.activity/csndsugui.py index 6ecf12e..5d60fcc 100755 --- a/playfile.activity/csndsugui.py +++ b/playfile.activity/csndsugui.py @@ -31,7 +31,7 @@ import pygtk pygtk.require('2.0') from sugar.activity import activity -import gtk +import gtk, gobject import sys import csnd import math @@ -349,7 +349,29 @@ class BasicGUI: label.show() self.set_channel(title, init) return slider - + + def numdisplay(self,box,title="",init=0.0,label=""): + self.ndispwids = self.ndispwids + 1 + entry = gtk.Entry() + if label == "": name = title + else: name = label + entry.set_text("%f" % init) + label = gtk.Label(name) + box.pack_start(entry, False, False, 2) + box.pack_start(label, False, False, 2) + self.ndisps.append([entry,title,init]) + entry.show() + label.show() + self.set_channel(title,init) + return entry + + def setnumdisp(self,title,val): + for i in self.ndisps: + if i[1] == title: + i[2] = val + i[0].set_text("%f" % val) + self.set_channel(title, val) + def spin(self,init, start, end, step, page, box, accel=0,title="",label=""): """Creates a spin button init: initial value @@ -576,6 +598,8 @@ class BasicGUI: self.mbuttons = [] self.mbutts = 0 self.boxes = [] + self.ndisps = [] + self.ndispwids = 0 self.connected = False self.channel_widgets = [self.sliders, self.spins, self.buttons] self.filenames = dict() @@ -642,6 +666,7 @@ class CsoundGUI(BasicGUI): self.replay = self.on self.logger.debug("focus_out and stopping") self.reset() + return 1 def play(self): """Starts a performance. """ @@ -734,6 +759,29 @@ class CsoundGUI(BasicGUI): self.reset() sys.exit(0) + def tcallback(self,cbdata): + if self.stopcb: return False + if self.on and self.sync: + self.tcb(cbdata) + return True + + def set_timer(self,time,cb,cbdata,sync=True): + """Sets a timer callback, called at time intervals. + Sync=True makes it start/stop with Csound performance""" + if(self.stopcb == True): + self.sync = sync + self.tcb = cb + self.stopcb = False + gobject.timeout_add(time,self.tcallback,cbdata) + + def stop_timer(self): + """Stops the timer""" + self.stopcb = True + + def score_time(self): + """Returns the current score time""" + return self.csound.GetScoreTime() + def __init__(self,act,colour=(-1,-1,-1),vert=True): """constructor act: activity object @@ -749,4 +797,4 @@ class CsoundGUI(BasicGUI): self.name = "0" self.arglist = None self.replay = False - + self.stopcb = True -- cgit v0.9.1