Building the score maker

Let us now build the score maker. This will display whatever is played on the piano in music notation. For the sake of program modularity, we will build the program in a separate file named score_maker.py.

We start by defining a class ScoreMaker. Since we will be showing just two octaves of notes, we will define a constant NOTES listing all the notes (7.06/score_maker.py):

class ScoreMaker:NOTES = ['C1','D1', 'E1', 'F1', 'G1','A1', 'B1', 'C2','D2', 'E2', 'F2', 'G2','A2', 'B2']

The __init__ method of this class takes the container as an argument. This is the container on which this class will draw the score (7.06/score_maker.py):

def __init__(self, container): self.canvas = Canvas(container, width=500, height = 110) ...

Get Tkinter GUI Application Development Blueprints - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.