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 complete patterns

Now our program has the ability to play any sound. But we don't just need to play a single sound. We need to play a pattern. Let's define a method called play_pattern, which reads our internal data structure and plays files accordingly (see code 3.06.py):

import time    def play_pattern(self):        self.now_playing = True        while self.now_playing:            play_list = self.get_is_button_clicked_list()            num_columns = len(play_list[0])            for column_index in range(num_columns):                column_to_play = self.get_column_from_matrix(                      play_list, column_index)                for i, item in enumerate(column_to_play):                    if item:                        sound_filename = self.get_drum_file_path(i)                        self.play_sound(sound_filename)                time.sleep(self.time_to_play_each_column()) if not self.now_playing: ...
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