def main(): fname = sys.argv[1] f = open(fname, "rt") text = f.read() root = Tkinter.Tk() # have to initialize the sound system, required!! tkSnack.initializeSnack(root) # set the volume of the sound system (0 to 100%) tg.setVolume(100) tg.translateNote('A4') notes = text.split() d = build_dict(notes) sent = generate_music(d) for i in sent: tg.translateNote(i) tg.soundStop() root.withdraw()
def PlaySong(self, event): if self.Songs != None: Player = self.ASH_Frame.Tools.Player if Player != None: Player.Stop() Player = None SongIndex = self.SongList.GetSelections()[0] SongName = self.Songs.keys()[SongIndex] SongPath = self.Songs[SongName] ServerUrl = self.ASH_Frame.Search.LastSearchServer + "songs/" RequestUrl = ServerUrl+SongPath SongFile = open("saves/.temp.wav", "wb") import urllib Song = urllib.urlopen(ServerUrl+SongPath) SongFile.writelines(Song.read()) SongFile.close() import player player.play(self.ASH_Frame) self.ASH_Frame.Tune.TkRoot = Tkinter.Tk() tkSnack.initializeSnack(self.ASH_Frame.Tune.TkRoot) self.ASH_Frame.Tune.SnackSound.write(".tempfile.wav") self.ASH_Frame.Tune.SnackSound = tkSnack.Sound(load=".tempfile.wav")
def __init__(self, wpm=10, frequency=500, noteshape='sine'): u"""Crea una nueva instancia de CodigoMorseSound. Argumentos: wpm -- Words Per Minute (Palabras Por Minuto)(default: 10) frequency -- Frecuencia de la nota en Hz (default: 500) noteshape -- Forma de onda de la nota. Los valores admitidos son: 'sine', 'triangle', 'rectangle', 'noise' y 'sampled' (default: 'sine') """ self.words_per_minute = wpm # Utilizar números flotantes debido a un problema en la división realizada # por el intérprete de Python 2.x self.time_unit = 1200.0 / wpm self.frequency = frequency self.tmp_dot = self.time_unit self.tmp_dash = self.tmp_dot * 3 self.tmp_inter_elements_space = self.tmp_dot self.tmp_space_between_letters = self.tmp_dot * 3 self.tmp_space_between_words = self.tmp_dot * 7 self._noteshape = noteshape self._filt = None # Inicialización necesaria para que funcione tkSnack. self._root = Tkinter.Tk() tkSnack.initializeSnack(self._root)
def __init__(self, master): self.is_playing = False self.is_opened = False self.filename = None self.RADIO_VARIABLE = StringVar() self.num_options = 0 self.options = [ 0 for i in range(0,MAX_FILES)] self.master = master self.frame_toolbar = Frame(master) self.frame_toolbar.pack() menu = Menu(master) master.config(menu=menu) tkSnack.initializeSnack(master) self.snd_main = tkSnack.Sound() self.frame_files = Frame(master) self.frame_files.pack(side=LEFT) frame_lower = Frame(master) frame_lower.pack(side=BOTTOM) self.lbl_result = Label(frame_lower,wraplength=300,text="") self.lbl_result.pack(side=LEFT) self.create_buttons(self.frame_toolbar) self.create_menu(menu)
def __init__(self, master): self.is_playing = False self.is_listening = False self.is_opened = False self.filename = None self.master = master self.frame_toolbar = Frame(master) self.frame_toolbar.pack() menu = Menu(master) master.config(menu=menu) tkSnack.initializeSnack(master) self.snd_main = tkSnack.Sound() self.frame_wave = Frame(master) self.frame_wave.pack(side=LEFT) self.sc = tkSnack.SnackCanvas(self.frame_wave, height=400) self.sc.pack(side=LEFT) self.sc.create_waveform(0, 0, sound=self.snd_main, height=100, zerolevel=1) self.sc.create_spectrogram(0, 150, sound=self.snd_main, height=200) frame_lower = Frame(master) frame_lower.pack(side=BOTTOM) self.lbl_remaining = Label(frame_lower,text="") self.lbl_remaining.pack(side=LEFT) self.lbl_result = Label(frame_lower,wraplength=250,text="") self.lbl_result.pack(side=LEFT) self.create_buttons(self.frame_toolbar) self.create_menu(menu)
def playsound(self): """ Play the Magic Word sound, if tkSnack is installed """ try: tkSnack.initializeSnack(self.consoleText) mysound = tkSnack.Sound() mysound.read('magicword.wav') mysound.play() except: print "[-] Cannot play sound"
def play(self, _filePath): if self.tada is not None: self.stop() from Tkinter import Tk import tkSnack self.root = Tk() tkSnack.initializeSnack(self.root) self.tada = tkSnack.Sound(file=_filePath) self.tada.play() return True
def main(): # Begin gui framework if os.path.exists('./temp.wav'): print './temp.wav already exists' sys.exit() root = Tk() root.title("Sonify") snack.initializeSnack(root) myGUI = GUI(root) root.resizable(False, False) root.mainloop()
def main(): # Catching command line options try: opts, args = getopt.getopt(sys.argv[1:], "p:r:") except getopt.GetoptError as err: print str(err) sys.exit(2) # Default values port = 9580 docroot = os.getenv('HOME') # Parsing command line options for o, a in opts: if o == "-p": port = int(a) elif o == "-r": docroot = a else: assert False, "Unhandled option" # Registering signal handler def sigint_handler(signal, frame): server.shutdown() sys.exit(0) signal.signal(signal.SIGINT, sigint_handler) # Creating Tk window for Snack win = Tkinter.Tk() # Initializing Snack tkSnack.initializeSnack(win) # Withdrawing Tk window, we don't need it after initializeSnack() win.withdraw() # Initiliazing Sound object sndobj = tkSnack.Sound() # Starting server thread server = MP3Server.MP3Server(('', port), MP3Server.PlayerHandler, sndobj, docroot) server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() # Dummy function to interrupt mainloop in order to handle signal int_for_signal(win) win.mainloop()
def main(): initOSCClient('127.0.0.1', 9001) sendOSCMsg("/start") fname = sys.argv[1] f = open(fname, "rt") text = f.read() root = Tkinter.Tk() # have to initialize the sound system, required!! tkSnack.initializeSnack(root) # set the volume of the sound system (0 to 100%) tg.setVolume(100) tg.translateNote('A4') notes = text.split() d = build_dict(notes) sent = generate_music(d) j = 0 for i in sent: # Nota mais grave vai pro cello i = tg.translateNote(i) # Sua terça vai pro violino 1 j = i * (4 / 5) # Sua quinta vai pra viola k = j * (3 / 2) # E sua oitava pro violino 2 l = i * 2 sendOSCMsg("/cello", [i]) sendOSCMsg("/viola", [j]) sendOSCMsg("/violin1", [k]) sendOSCMsg("/violin2", [l]) time.sleep(0.5) # tg.soundStop() sendOSCMsg("/cello", [0]) sendOSCMsg("/viola", [0]) sendOSCMsg("/violin1", [0]) sendOSCMsg("/violin2", [0]) sendOSCMsg("/stop") closeOSC() root.withdraw()
def main(): initOSCClient('127.0.0.1', 9001) sendOSCMsg("/start") fname = sys.argv[1] f = open(fname, "rt") text = f.read() root = Tkinter.Tk() # have to initialize the sound system, required!! tkSnack.initializeSnack(root) # set the volume of the sound system (0 to 100%) tg.setVolume(100) tg.translateNote('A4') notes = text.split() d = build_dict(notes) sent = generate_music(d) j = 0 for i in sent: # Nota mais grave vai pro cello i = tg.translateNote(i) # Sua terça vai pro violino 1 j = i*(4/5) # Sua quinta vai pra viola k = j*(3/2) # E sua oitava pro violino 2 l = i*2 sendOSCMsg("/cello", [i]) sendOSCMsg("/viola", [j]) sendOSCMsg("/violin1", [k]) sendOSCMsg("/violin2", [l]) time.sleep(0.5) # tg.soundStop() sendOSCMsg("/cello", [0]) sendOSCMsg("/viola", [0]) sendOSCMsg("/violin1", [0]) sendOSCMsg("/violin2", [0]) sendOSCMsg("/stop") closeOSC() root.withdraw()
def main(path): Tags=[] root = Tkinter.Tk() tkSnack.initializeSnack(root) Song = ConstructTags() for Song_Name in os.listdir(path): Song_Path = path+Song_Name Song.load(Song_Path) Slope, max_list, min_list = Song.get_tags() Tags.append({"Name":Song_Name, "Path":Song_Path, "Slope":Slope, "MaxList":max_list, "MinList":min_list}) # print len(Tags) del(root) return Tags
def __init__ (self,Frame,Panel): self.ASH_Frame = Frame wx.StaticBoxSizer.__init__(self,wx.StaticBox(Panel, -1, label='Tune'), wx.VERTICAL) self.Time = wx.StaticText(Panel, label="Time : 0 Sec") self.Title = wx.StaticText(Panel, size=(250,20), label="untitled.wav", style=wx.ALIGN_CENTER) Img = wx.Image('icons/wave.jpg', wx.BITMAP_TYPE_ANY) self.Waveform = wx.StaticBitmap(Panel, -1, Img.ConvertToBitmap(), size=(270,200)) self.Add(self.Time, 0, wx.ALL, border=5) self.Add(self.Waveform, 0, wx.ALL, border=1) self.Add(self.Title, 0, wx.BOTTOM, border=5) self.TuneName = None self.TkRoot = Tkinter.Tk() tkSnack.initializeSnack(self.TkRoot) self.SnackSound = tkSnack.Sound()
def main(): root = tk.Tk() if (useTkSnack) : print("using TkSnack") tkSnack.initializeSnack(root) snd = tkSnack.Sound() else : print("not using TkSnack") snd = None width = 800 height = 700 # ("<width>x<height>+<xcoords>+<ycoords>") root.geometry("%sx%s+80+70" % (width, height) ) app = Application(root, snd, width, height) # CJR testing to see if this will stop the proces on X window closure root.protocol('WM_DELETE_WINDOW', app.exitApp) root.mainloop()
def OnRecord(self, event): import tune, Tkinter, tkSnack tune.recorder(self.ASH_Frame) self.ASH_Frame.Tune.TkRoot = Tkinter.Tk() tkSnack.initializeSnack(self.ASH_Frame.Tune.TkRoot) self.ASH_Frame.Tune.SnackSound.write(".tempfile.wav") self.ASH_Frame.Tune.SnackSound = tkSnack.Sound(load=".tempfile.wav") if tune.IS_RECORDED: self.ASH_Frame.Tune.TuneName = "saves/.temp.wav" self.ASH_Frame.Tune.SnackSound.read("saves/.temp.wav") T = self.ASH_Frame.Tune.SnackSound.length(unit="SECONDS") if T < 10: Time = "Tune too short!" elif T > 20: Time = "Tune too long!" else: Time = "Time : " + str() + "Sec" self.ASH_Frame.Tune.Time.SetLabel(Time) self.ASH_Frame.Tune.DrawGraph()
def main(path): Tags = [] root = Tkinter.Tk() tkSnack.initializeSnack(root) Song = ConstructTags() for Song_Name in os.listdir(path): Song_Path = path + Song_Name Song.load(Song_Path) Slope, max_list, min_list = Song.get_tags() Tags.append({ "Name": Song_Name, "Path": Song_Path, "Slope": Slope, "MaxList": max_list, "MinList": min_list }) # print len(Tags) del (root) return Tags
def __init__(self, master): self.is_playing = False self.filename = None self.is_opened = False self.filename = None self.num_options = 0 self.options = [ 0 for i in range(0,MAX_FILES)] self.master = master self.frame_toolbar = Frame(master) self.frame_toolbar.pack() menu = Menu(master) master.config(menu=menu) tkSnack.initializeSnack(master) self.snd_main = tkSnack.Sound() frame_lower = Frame(master) frame_lower.pack(side=BOTTOM) self.lbl_result = Label(frame_lower,wraplength=300,text="") self.lbl_result.pack(side=LEFT) self.create_buttons(self.frame_toolbar) self.create_menu(menu) self.frame_options = Frame(master) self.frame_options.pack() lbl_is_copyright = Label(self.frame_options,text='Is Copyright? (y/n)').pack(side=LEFT) self.is_copyright = Entry(self.frame_options) self.is_copyright.pack(side=LEFT) lbl_copyright_holder = Label(self.frame_options,text='Copyright Holder').pack(side=LEFT) self.copyright_holder = Entry(self.frame_options) self.copyright_holder.pack(side=LEFT) self.btn_submit = Button(self.frame_options,text='Submit',command=self.do_submit).pack(side=LEFT)
def __init__(self): Tk.__init__(self) #local state variables self.playstate=0 #This var is for changing between play/pause self.playing=0 #This var is set to 1 once something has started playing self.song="" #This holds the current sound var self.track=0 #This holds the current track self.last=0 #This flag is used to tell if the song is the last in the list self.title("pyTunes") #Window placement in screen self.sw = self.winfo_screenwidth() self.sh = self.winfo_screenheight() w =390 h = 100 x = (self.sw-w)/2 y = (self.sh-h)/2 self.geometry('%dx%d+%d+%d' % (w,h,x,y)) #Window Layout self.title("pyTunes") self.columnconfigure(7, weight=1) self.rowconfigure(3,weight=1) self.Play_Button = Button(self, text = " Play ", command=self.Play, state=DISABLED) self.Play_Button.grid(row=0, column=0, sticky=N+E+S+W) self.Stop_Button = Button(self, text = "Stop", command=self.Stop, state=DISABLED) self.Stop_Button.grid(row=0, column=1, sticky=N+E+S+W) self.Next_Button = Button(self, text = ">>|", command=self.Next, state=DISABLED) self.Next_Button.grid(row=1, column = 1, sticky=N+E+S+W) self.Prev_Button = Button(self, text = "|<<", command=self.Prev, state=DISABLED) self.Prev_Button.grid(row=1, column = 0, sticky=N+E+S+W) #Menubar setup stuff self.menubar = Menu(self) self.filemenu = Menu(self.menubar) self.filemenu.add_command(label="Open File", command=self.FileOpen) self.filemenu.add_command(label="Save Playlist As", command=NotDoneYet) self.filemenu.add_command(label="Load Playlist", command=NotDoneYet) self.filemenu.add_command(label="Exit", command=self.destroy) self.menubar.add_cascade(label="File", menu=self.filemenu) self.viewmenu = Menu(self.menubar) self.viewmenu.add_command(label="Show Playlist", command=self.ShowPlaylist) self.menubar.add_cascade(label="View", menu=self.viewmenu) self.playlistmenu = Menu(self.menubar) self.playlistmenu.add_command(label="Play Next", command = self.Next) self.playlistmenu.add_command(label="Play Previous", command = self.Prev) self.playlistmenu.add_command(label="Play Playlist", command = self.PlayPlaylist) self.menubar.add_cascade(label="Playback", menu=self.playlistmenu) self.aboutmenu = Menu(self.menubar) self.aboutmenu.add_command(label="About", command = self.ShowAbout) self.menubar.add_cascade(label="Help", menu=self.aboutmenu) self.shuffle = IntVar() self.shuffle_check = Checkbutton(self.master, text = "Shuffle Enable", variable=self.shuffle) self.shuffle_check.grid(row=0, column=5, sticky=N+E+S+W) self.repeat = IntVar() self.repeat_check = Checkbutton(self.master, text = "Repeat Enable", variable=self.repeat) self.repeat_check.grid(row=1, column=5, sticky=N+E+S+W) self.config(menu=self.menubar) #Scrollbars! self.vol_Scale = Scale(self, from_ =0, to=100, orient=HORIZONTAL, command=self.onScaleVol) self.vol_Scale.grid (row=2, column=0, sticky=N+E+S+W) self.vol = IntVar() self.tracking_Scale = Scale(self, from_ =0, to=100, orient=HORIZONTAL) self.tracking_Scale.grid(row=2, column=1, columnspan=2 , sticky=N+E+S+W) self.tracking = IntVar() #Window initialization stuff tkSnack.initializeSnack(self) self.PlaylistWindow=PlaylistWindow(self) self.AboutWindow=AboutWindow(self) self.mainloop()
import win32ui import win32print import win32con import os click = 'buttonclick.wav' col1 = 'black' col2 = 'red' path = 'g:/programming/python/encoder/' usr = '' passw = '' tag = '' root = Tk() tkSnack.initializeSnack(root) root.title('Encoder') root.config(bg = col1) class password: def __init__(self,parent): self.d = 0 self.frame = Frame(parent) self.frame.pack() self.e = StringVar() self.entry = Entry(self.frame, textvariable = self.e) self.entry.config(disabledforeground = 'dark gray', disabledbackground = col1, width = 20, font = ('Arial',12), borderwidth = 3, bg = col1, fg = col2) self.e.set('Username') self.entry.bind('<Return>', self.enter2)
import pickle from copy import deepcopy import functions as func import hand_detector as hd import Tkinter import tkSnack import playnotes frame = 0 frequencies = [ 175, 196, 220, 247, 262, 294, 330, 350, 392, 440, 494, 523, 587, 659, 698, 784, 880, 988, 1047 ] root = Tkinter.Tk() tkSnack.initializeSnack(root) choose = True tracking = False vfile = 0 draw_contours = False colors = np.int32(list(np.ndindex(3, 3, 3))) * 127 #colors to segment keyboard cap = cv2.VideoCapture(vfile) #read in video or open camera ret, ref_shad = cap.read() #first frame is reference image markers, reflist, ref_centers = func.setVars(choose, ref_shad) #set variables ref_image = cv2.imread('dref_image.jpg') #have untouched ref image #Segment the keyboard marks, boundary = func.get_keys_from_markers(ref_image, markers) overlay = colors[np.maximum(marks, 0) % 27] vis = cv2.addWeighted(ref_image, 0.5, overlay, 0.5, 0.0, dtype=cv2.CV_8UC3)
def main(): DOCROOT_LABEL = 'Document root:' PORT_LABEL = 'Listen on port:' APPNAME = 'PIPlayD' TEXT_HEIGHT = 1 MF_WIDTH = 400 MF_HEIGHT = 150 BUT_WIDTH = 30 BUT_HEIGHT = 30 START_COLOR = 'green' DEFAULT_PORT = '9580' server = None sndobj = None # Loading main window win = Tkinter.Tk(baseName = APPNAME) win.wm_title(APPNAME) # Setting main frame f = Tkinter.Frame(win, width = MF_WIDTH, height = MF_HEIGHT) f.pack_propagate(False) # Setting labels label_DocRoot = Tkinter.Label(f, text = DOCROOT_LABEL) label_Port = Tkinter.Label(f, text = PORT_LABEL) # Setting text areas text_DR = Tkinter.Entry(f) text_DR.insert(0, os.getenv('HOME')) text_P = Tkinter.Entry(f) text_P.insert(0, DEFAULT_PORT) # Handlers for buttons def stopServer(): global server server.shutdown() del server def startServer(): global server port = int(text_P.get()) server = MP3Server.MP3Server(('', port), MP3Server.PlayerHandler, sndobj, text_DR.get()) server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = True server_thread.start() # Setting buttons but_Stop = ControlButton(f, BUT_WIDTH, BUT_HEIGHT, 'stop', command = stopServer) but_Start = ControlButton(f, BUT_WIDTH, BUT_HEIGHT, 'start', command = startServer) # Initilizing tkSnack tkSnack.initializeSnack(win) sndobj = tkSnack.Sound() # Designign layout f.grid() label_DocRoot.grid(row = 1, column = 1, sticky = Tkinter.W) text_DR.grid(row = 1, column = 2, sticky = Tkinter.W, columnspan = 2) label_Port.grid(row = 2, column = 1, sticky = Tkinter.W) text_P.grid(row = 2, column = 2, sticky = Tkinter.W, columnspan = 2) but_Stop.grid(row = 3, column = 2) but_Start.grid(row = 3, column = 3) win.mainloop()
def init_tk(): root = Tkinter.Tk() tkSnack.initializeSnack(root) tkSnack.audio.play_gain(100) global snd snd = tkSnack.Sound()
def initialiseSounds(self): tkSnack.initializeSnack(self.root) self.recordedAudio = Sound() self.soundCopy = Sound() self.loadedAudio = Sound()
self.socket.close() sys.stdout.flush() sys.stderr.flush() def restart(self): os.execl(sys.argv[0], sys.argv[0], sys.argv[1], sys.argv[2]) def sighandler(self, signo, frame): self.cleanup() if signo == signal.SIGHUP: self.after(100, self.restart) else: sys.exit(0) def create_pidfile(): with open(sys.argv[2], "w") as f: print >> f, os.getpid() def delete_pidfile(): os.remove(sys.argv[2]) tkSnack.initializeSnack(Tkinter.Tk()) Tkinter.Tk.report_callback_exception = GenWaveForm.show_error root = GenWaveForm() signal.signal(signal.SIGTERM, root.sighandler) signal.signal(signal.SIGHUP, root.sighandler) root.mainloop()
import tkFileDialog as fd from Tkinter import * from os import getcwd from tkSnack import initializeSnack,Sound import config as settings cwd = getcwd() win = Tk() initializeSnack(win) class single(object): def __init__(self, pos=[0,0]): self.img = PhotoImage(file="%s/icons/%s/button_off.gif" % (cwd,settings.gui["icons"])) self.but = Button(win, image=self.img, command=lambda: self.switch()) self.state = False self.but.grid(row=pos[0], column=pos[1]) def switch(self): if self.state==False: self.state = True self.img = PhotoImage(file="%s/icons/%s/button_on.gif" % (cwd,settings.gui["icons"])) self.but.configure(image=self.img) else: self.state = False self.img = PhotoImage(file="%s/icons/%s/button_off.gif" % (cwd,settings.gui["icons"])) self.but.configure(image=self.img) def active(self, st=False): high = "" state = "off" if self.state==True: state = "on" if st==True: high = "_highlight" self.img = PhotoImage(file="%s/icons/%s/button_%s%s.gif" % (cwd,settings.gui["icons"],state,high)) self.but.configure(image=self.img) class row(object):
mcp.setFunction(LED3, 0) mcp.setFunction(LED4, 0) mcp.setFunction(LED5, 0) mcp.setFunction(LED6, 0) mcp.setFunction(LED7, 0) GPIO.setFunction(SWITCH,GPIO.IN) # Set Switch as input #Method to play a note using tkSnack def playNote(freq,duration): snd = tkSnack.Sound() filt = tkSnack.Filter('generator', freq, 30000, 0.0,'sine', int(11500*duration)) snd.stop() snd.play(filter=filt, blocking =1) # Initialize sound system tkSnack.initializeSnack(Tkinter.Tk()) # Calling on reading method in DistanceSensor class sensor = DistanceSensor() # Loop for ever while True: # Only run if the switch button is pressed if (GPIO.digitalRead(SWITCH) == GPIO.HIGH): # Take a distance measurement distance = sensor.reading(0) # If distance if between 0 and 5 # --> light all LEDs and play note if (distance>0 and distance<5): mcp.portWrite(0) playNote(1047,1)
def __init__(self): Tk.__init__(self) #local state variables self.playstate=0 #This var is for changing between play/pause self.playing=0 #This var is set to 1 once something has started playing self.song="" #This holds the current sound var self.track=0 #This holds the current track self.last=0 #This flag is used to tell if the song is the last in the list self.title("pyTunes") #Window placement in screen self.sw = self.winfo_screenwidth() self.sh = self.winfo_screenheight() w =380 h = 60 x = (self.sw-w)/2 y = (self.sh-h)/2 self.geometry('%dx%d+%d+%d' % (w,h,x,y)) #Window Layout self.title("pyTunes") self.columnconfigure(5, weight=1) self.rowconfigure(0,weight=1) self.Play_Button = Button(self, text = " Play ", command=self.Play, state=DISABLED) self.Play_Button.grid(row=0, column=1, sticky=N+E+S+W) self.Stop_Button = Button(self, text = "Stop", command=self.Stop, state=DISABLED) self.Stop_Button.grid(row=0, column=2, sticky=N+E+S+W) self.Next_Button = Button(self, text = ">>|", command=self.Next, state=DISABLED) self.Next_Button.grid(row=1, column = 2, sticky=N+E+S+W) self.Prev_Button = Button(self, text = "|<<", command=self.Prev, state=DISABLED) self.Prev_Button.grid(row=1, column = 1, sticky=N+E+S+W) self.VolUP_Button = Button(self, text = "Vol UP", command=self.VolUP) self.VolUP_Button.grid(row=0, column=0, sticky=N+E+S+W) self.VolDN_Button = Button(self, text = "Vol DN", command=self.VolDN) self.VolDN_Button.grid(row=1, column=0, sticky=N+E+S+W) self.Splist_Button = Button(self, text = "Show Playlist", command=self.ShowPlaylist) self.Splist_Button.grid(row=0, column=3, sticky=N+E+S+W) self.Pplist_Button = Button(self, text = "Play Playlist", command=self.PlayPlaylist) self.Pplist_Button.grid(row=1, column=3, sticky=N+E+S+W) self.OpenFile_Button = Button(self, text = "Open File", command=self.FileOpen) self.OpenFile_Button.grid(row=0, column=4, rowspan=2, sticky=N+E+S+W) tkSnack.initializeSnack(self) self.PlaylistWindow=PlaylistWindow(self) self.mainloop()
def __init__(self, master): self.master = master self.master.title('Schedule') # initialize widgets self.time_table = TimeTable(self.master) self.time_table.grid(row=0, column=0) self.panel = tk.Frame(self.master, height=50, width=200) self.panel.grid(row=1, column=0) # bottom panel self.refresh_button = tk.Button(self.panel, text='Refresh', command=self.refresh) self.refresh_button.grid(row=0, column=0) self.auto_refresh = tk.IntVar() self.auto_refresh_button = tk.Checkbutton(self.panel, text = 'Auto Refresh', \ variable = self.auto_refresh, command = self.set_auto_refresh) self.auto_refresh_button.grid(row=0, column=1) self.option_button = tk.Button(self.panel, text='Options', command=self.pop_option_panel) self.option_button.grid(row=0, column=2) self.reinitialize_button = tk.Button(self.panel, text = 'Reinitialize', \ command = self.initialize) self.reinitialize_button.grid(row=0, column=3) # LED path led_on = tk.PhotoImage(file=os.path.join(ABSOLUTE_PATH, 'led_on.png')) led_off = tk.PhotoImage( file=os.path.join(ABSOLUTE_PATH, 'led_off.png')) fake_led = LED(None) # set the image path in the LED class fake_led.set_image(led_on, led_off) fake_led.destroy() # pop-up windows self.wake_up_window = None self.option_panel = None self.option_panel_open = False # initialize schedule self.schedule_path = self._get_schedule_path() self.sc = DisplayableSchedule(self.master) self.initialize() # initialize alarm self.music_path = os.path.join(ABSOLUTE_PATH, MUSIC_PATH) tkSnack.initializeSnack(self.master) tkSnack.audio.inputDevices() self.music = tkSnack.Sound() self.music.read(self.music_path) # intialize time data self.last_refresh = 0 self.update_sync = True # avoids starting the alarm while the schedule is refreshed self.update_period = UPDATE_PERIOD self.refresh_period = REFRESH_PERIOD self.time_before_start = TIME_BEFORE_START self.update()
def __init__(self, master): """ Run a set of timers concurrently - clear_mind (default 5 minutes) - study (default 30 minutes) - review (default 5 minutes) - break (15 minutes) """ super().__init__(master) self.master = master # tkSnack used to play sound tkSnack.initializeSnack(self.master) self.snd = tkSnack.Sound() self.snd.read("media/gong.wav") self.minutes = self.seconds = 0 self.minute_vals = [5, 30, 5, 15] self.stop_timer = False self.clear_mind_label_text = tk.StringVar() self.study_label_text = tk.StringVar() self.review_label_text = tk.StringVar() self.relax_label_text = tk.StringVar() self.clear_mind_input_value = tk.StringVar() self.study_input_value = tk.StringVar() self.review_input_value = tk.StringVar() self.relax_input_value = tk.StringVar() self.error_message = tk.StringVar() self.clocks = ( self.clear_mind_label_text, self.study_label_text, self.review_label_text, self.relax_label_text, ) self.current_row = 0 self.line_label = 0 self.entry_colomn = 1 self.set_entry_column = 2 self.time_column = 3 # ------ styles ----------- self.error_style = ttk.Style() self.error_style.configure('Error.TLabel', foreground='red', background="#5cdb95", font=('Sans', '10', 'bold')) self.title_label_style = ttk.Style() self.title_label_style.configure('Title.TLabel', font=('Sans', '12', 'bold'), background="#5cdb95") self.button_style = ttk.Style() self.button_style.configure('Nice.TButton', foreground='#05386b', background='#5cdb95') self.entry_style = ttk.Style() self.entry_style.configure('Nice.TEntry', fieldbackground='#8ee4af') self.label_style = ttk.Style() self.label_style.configure('Nice.TLabel', background="#5cdb95") self.line_style = ttk.Style() self.line_style.configure('Line.TSeparator', background="#05386b") self.frame_style = ttk.Style() self.frame_style.configure('Nice.TFrame', background="#5cdb95") self.initUI() self.set_vals()
def initialize_player(self): tkSnack.initializeSnack(root) #standard init process tkSnack self.soundObject = tkSnack.Sound( ) #create a SoundObject (required by tkSnack)