We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 06e534b commit c586fe0Copy full SHA for c586fe0
docs/examples/music_box.py
@@ -5,14 +5,12 @@
5
6
pygame.mixer.init()
7
8
-sound_pins = {
9
- 2: Sound("samples/drum_tom_mid_hard.wav"),
10
- 3: Sound("samples/drum_cymbal_open.wav"),
+button_sounds = {
+ Button(2): Sound("samples/drum_tom_mid_hard.wav"),
+ Button(3): Sound("samples/drum_cymbal_open.wav"),
11
}
12
13
-buttons = [Button(pin) for pin in sound_pins]
14
-for button in buttons:
15
- sound = sound_pins[button.pin.number]
+for button, sound in button_sounds.items():
16
button.when_pressed = sound.play
17
18
pause()
0 commit comments