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)、POOL PUZZLE(p.379)を解いてみる。
POOL PUZZLE(p.379)
コード(BBEdit)
sample379.py
#!/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
import os
def shutdown():
mixer.stop()
app.destroy()
app = Tk()
app.title('Head First Mix')
mixer = pygame.mixer
mixer.init()
dirList = os.listdir(".")
for filename in dirList:
if filename.endswith('.wav'):
panel = sound_panel.SoundPanel(app, mixer, filename)
panel.pack()
app.protocol('WM_DELETE_WINDOW', shutdown)
app.mainloop()
入出力結果(Terminal)
$ ./sample379.py $
0 コメント:
コメントを投稿