Head First Programming
A learner's guide to programming
using the Python language
( O'Reilly Media)
David Griffiths (著) Paul Barry (著)
開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Head First Programming A learner's guide to programming using the Python language (David Griffiths(著)、Paul Barry(著)、 O'Reilly Media )のChapter 11(Custom Widgets and Classes: With an object in mind)、EXERCISE(p.359)を解いてみる。
EXERCISE(p.359)
コード(BBEdit)
hfmix.pyw
#!/usr/bin/env python2.7
#-*- coding: utf-8 -*-
# python3.xではtkinter, python2.xではTkinter
# python3.xでpygame.mixerモジュールを上手くインストールできてないので2.7を使用
from Tkinter import *
import pygame.mixer
import sound_panel
def shutdown():
mixer.stop()
app.destroy()
app = Tk()
app.title('Head First Mix')
mixer = pygame.mixer
mixer.init()
sound_files = ['39147_M_RED_beep_line.wav',
'39484__M_RED__trance_trumpet_loop.wav',
'39607__M_RED__trumpet_delay_loop.wav',
'49119_M_RED_HardBouncer.wav',
'50459_M_RED_Nephlimizer.wav']
for sound_file in sound_files:
sound_panel.createGuiApp(app, mixer, sound_file)
app.protocol('WM_DELETE_WINDOW', shutdown)
app.mainloop()
入出力結果(Terminal)
$ ./hfmix.pyw $
0 コメント:
コメントを投稿