1#! /usr/bin/env python 2 3from Tkinter import * 4from tkSnack import * 5 6root = Tkinter.Tk() 7 8initializeSnack(root) 9 10snd1 = Sound() 11snd2 = Sound() 12 13map1 = Filter('map', 1.0) 14map2 = Filter('map', 1.0) 15 16def play(): 17 snd1.play(filter=map1) 18 snd2.play(filter=map2) 19 20def stop(): 21 snd1.stop() 22 snd2.stop() 23 24def config(arg): 25 map1.configure(scale1.get()) 26 map2.configure(scale2.get()) 27 28def load1(): 29 filename = root.tk.call('eval', 'snack::getOpenFile') 30 snd1.config(file=filename) 31 32def load2(): 33 filename = root.tk.call('eval', 'snack::getOpenFile') 34 snd2.config(file=filename) 35 36 37f = Frame(root) 38f.pack() 39 40scale1 = Scale(f, from_=1.0, to=0, resolution=0.01, label="sound 1", command=config) 41scale1.pack(side='left') 42 43scale2 = Scale(f, from_=1.0, to=0, resolution=0.01, label="sound 2", command=config) 44scale2.pack(side='left') 45 46scale1.set(1.0) 47scale2.set(1.0) 48 49fb = Frame(root) 50fb.pack(side='bottom') 51Button(fb, text='load 1', command=load1).pack(side='left') 52Button(fb, text='load 2', command=load2).pack(side='left') 53Button(fb, bitmap='snackPlay', command=play).pack(side='left') 54Button(fb, bitmap='snackStop', command=stop).pack(side='left') 55 56root.mainloop() 57