diff options
author | James <olpc@localhost.localdomain> | 2007-02-26 07:59:00 (GMT) |
---|---|---|
committer | James <olpc@localhost.localdomain> | 2007-02-26 07:59:00 (GMT) |
commit | b91bd03107f5c8fd1eff166e18e888a1c6d3f1a9 (patch) | |
tree | 5c81997f09c73519674b25cdc6fd58478c05356b /Welcome.py | |
parent | 7e9d820bfdcb9cc627efe22a3f984ebaea47cd41 (diff) |
m
Diffstat (limited to 'Welcome.py')
-rw-r--r-- | Welcome.py | 58 |
1 files changed, 41 insertions, 17 deletions
@@ -5,16 +5,16 @@ import gtk import Config from Util.ThemeWidgets import * + +from Util.CSoundClient import new_csound_client +from Util.NoteDB import Note +from miniTamTam.RythmGenerator import generator +from SubActivity import SubActivity -class Welcome(gtk.EventBox): +class Welcome(SubActivity): - def __init__(self): - gtk.EventBox.__init__(self) - - self.draw() - self.show_all() - - def draw(self): + def __init__(self, set_mode): + SubActivity.__init__(self, set_mode) actVBox = RoundVBox(fillcolor = Config.WS_BCK_COLOR, bordercolor = Config.WS_BCK_COLOR, radius = Config.PANEL_RADIUS) actHBox = gtk.HBox() @@ -24,6 +24,7 @@ class Welcome(gtk.EventBox): actBtnBox.set_size_request(200,200) actBtnBox.set_border_width(Config.PANEL_SPACING) actBtn = ImageButton(Config.IMAGE_ROOT + activity +'Tam.png') + actBtn.connect('clicked', self.onActivityBtnClicked, activity) actBtnBox.pack_start(actBtn,True,False,0) actHBox.pack_start(actBtnBox,True,False,0) @@ -33,13 +34,36 @@ class Welcome(gtk.EventBox): actVBox.pack_start(actHBox,False,False, 100) actVBox.pack_start(title,False,False, 30) self.add(actVBox) + self.show_all() + self.activate_count = 0 -if __name__ == "__main__": - win = gtk.Window() - wc = Welcome() - win.add(wc) - win.show() - #start the gtk event loop - gtk.main() - -
\ No newline at end of file + def onActivityBtnClicked(self, widget, data): + self.set_mode(data) + + def onActivate(self): + def flatten(ll): + rval = [] + for l in ll: + rval += l + return rval + if self.activate_count == 0: + i = 0 + csnd = new_csound_client() + csnd.loopClear() + beat = 8 + regularity = 0.77 + reverb = 0.2 + for x in flatten( generator('drum3kit', beat, regularity, reverb) ): + n = Note(0, x.trackId, i, x) + i = i + 1 + csnd.loopPlay(n) + csnd.loopSetNumTicks( beat * Config.TICKS_PER_BEAT) + csnd.loopSetTick(0) + csnd.loopStart() + self.activate_count = self.activate_count + 1 + + def onDeactivate(self): + if (self.activate_count == 1): + csnd = new_csound_client() + csnd.loopPause() + csnd.loopClear() |