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

Determining the tempo of a rhythm

The mathematics of defining the tempo of a rhythm is simple. We get the value associated with the beats_per_minute attribute and divide it by 60 to get the beats per second. Then, the time to play each beat (or group of beats simultaneously for a given column) is the reciprocal of beats_per_second.

The code is as follows (see code 3.06.py):

def time_to_play_each_column(self):  beats_per_second = self.beats_per_minute/60  time_to_play_each_column = 1/beats_per_second  return time_to_play_each_column

While we are handling the tempo for the pattern, let's also complete coding of the command callback attached to our beats per minute Spinbox widget (see code 3.06.py):

def on_beats_per_minute_changed(self): self.beats_per_minute ...
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