Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Playing audio

To begin with, we have added 24 sound samples in .wav format in a folder named sounds in this chapter's code folder. These audio files correspond to the 24 notes on our keyboard. The audio files are named according to the note name it represents.

In order to keep the audio processing separate from the GUI code, we create a new file called audio.py (7.03). The code is defined as follows:

import simpleaudio as safrom _thread import start_new_threadimport timedef play_note(note_name): wave_obj = sa.WaveObject.from_wave_file('sounds/' + note_name + '.wav') wave_obj.play()def play_scale(scale): for note in scale:   play_note(note)   time.sleep(0.5)def play_scale_in_new_thread(scale):  start_new_thread(play_scale,(scale,))def play_chord(scale): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content