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

Making the piano keyboard

Let's now build the piano keyboard. All keys on the keyboard will be made using the Label widget. We will superimpose the label widget with an image of black and white keys using Tkinter's PhotoImage class.

The PhotoImage class is used to display images in label, text, button, and canvas widgets. We used it in Chapter 2, Making a Text Editor to add icons to buttons. Since this class can only handle .gif or .bpm format images, we add four .gif images to a folder named pictures. These four images are black_key.gif, white_key.gif, black_key_pressed.gif, and white_key_pressed.gif.

Since we will refer to these images over and over again, we add their reference to 7.02 constants.py:

WHITE_KEY_IMAGE = '../pictures/white_key.gif' ...
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