開発環境
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- Python 3.5 (プログラミング言語)
Python for Kids: A Playful Introduction to Programming (Jason R. Briggs (著) 、No Starch Press)のPart Ⅰ.(Learning to Program)、Chapter 12.(Using tkinter for Better Graphics)、Programming Puzzles #3: The Moving Photo(No. 3603)を解いてみる。
Programming Puzzles #3: The Moving Photo(No. 3603)
コード(Emacs)
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import time
import tkinter
app = tkinter.Tk()
canvas = tkinter.Canvas(app, width=400, height=200)
canvas.pack()
my_image = tkinter.PhotoImage(file='/Users/kamimura/Desktop/kamimura.gif')
canvas_id = canvas.create_image(0, 0, anchor=tkinter.NW, image=my_image)
def app_move(c, x, y):
for a in range(c):
canvas.move(canvas_id, x, y)
app.update()
time.sleep(0.05)
for c, x, y in [(60, 5, 0), (30, 0, 5), (60, -5, 0), (30, 0, -5)]:
app_move(c, x, y)
入出力結果(Terminal, IPython)
$ ./sample3.py $
0 コメント:
コメントを投稿