回答編集履歴

6

ログファイル名の修正、2.x 対応(文字コード指定)

2020/04/02 15:38

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -60,7 +60,9 @@
60
60
 
61
61
  ```python
62
62
 
63
+ # -*- coding: utf-8 -*-
64
+
63
- # 実行方法: python record_motion.py > handwriting-apple.txt
65
+ # 実行方法: python record_motion.py > motion.log
64
66
 
65
67
  from turtle import *
66
68
 
@@ -70,7 +72,7 @@
70
72
 
71
73
  # import sys
72
74
 
73
- # sys.stdout = open("handwriting-apple.txt", "w", encoding="utf-8")
75
+ # sys.stdout = open("motion.log", "w", encoding="utf-8")
74
76
 
75
77
 
76
78
 
@@ -122,11 +124,15 @@
122
124
 
123
125
  ```
124
126
 
127
+ # -*- coding: utf-8 -*-
128
+
129
+
130
+
125
131
  from turtle import *
126
132
 
127
133
 
128
134
 
129
- with open("handwriting-apple.txt", encoding="utf-8") as stream:
135
+ with open("motion.log", encoding="utf-8") as stream:
130
136
 
131
137
  write("Apple", None, "center", "serif 64 bold")
132
138
 
@@ -176,7 +182,7 @@
176
182
 
177
183
 
178
184
 
179
- handwriting-apple.txt の出力例
185
+ motion.log の出力例
180
186
 
181
187
  ```
182
188
 

5

リダイレクトについて、スクリプト内で出来るように追記

2020/04/02 15:38

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -66,6 +66,14 @@
66
66
 
67
67
 
68
68
 
69
+ # リダイレクトがうまくいかない場合以下の2行を有効にしてみてください
70
+
71
+ # import sys
72
+
73
+ # sys.stdout = open("handwriting-apple.txt", "w", encoding="utf-8")
74
+
75
+
76
+
69
77
  s = Screen()
70
78
 
71
79
  t = Turtle()

4

記録~再生の手順を追加

2020/04/01 13:30

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -19,6 +19,14 @@
19
19
  (ペンタブ等使えばもう少し綺麗に書けるかも・・)
20
20
 
21
21
  3. 座標データを読み込み描画アニメーションとして再生するプログラムを作成
22
+
23
+
24
+
25
+
26
+
27
+ 追記: 記録~再生の手順
28
+
29
+ ![イメージ説明](27cc8e16d39d0fb16da80deaa62c0124.gif)
22
30
 
23
31
 
24
32
 

3

サンプルコードにファイル名追加。handwriting-apple.txt の出力例を追加

2020/04/01 13:24

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
 
50
50
 
51
- 記録用
51
+ 記録用(record_motion.py) リダイレクト付きで実行してください
52
52
 
53
53
  ```python
54
54
 
@@ -102,7 +102,7 @@
102
102
 
103
103
 
104
104
 
105
- 再生用
105
+ 再生用(replay_motion.py)
106
106
 
107
107
  ```
108
108
 
@@ -155,3 +155,31 @@
155
155
  done()
156
156
 
157
157
  ```
158
+
159
+
160
+
161
+
162
+
163
+ handwriting-apple.txt の出力例
164
+
165
+ ```
166
+
167
+ pendown 390 332
168
+
169
+ setpos 390 333
170
+
171
+ setpos 390 334
172
+
173
+ setpos 390 335
174
+
175
+ setpos 390 337
176
+
177
+ :
178
+
179
+ :
180
+
181
+ :
182
+
183
+ ```
184
+
185
+ このような感じに、マウスをドラッグ中に通った座標が記録されます。

2

インデント修正

2020/03/31 11:44

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -72,21 +72,21 @@
72
72
 
73
73
  def onrelease(e):
74
74
 
75
- print("penup")
75
+ print("penup")
76
76
 
77
- s.cv.unbind("<Motion>")
77
+ s.cv.unbind("<Motion>")
78
78
 
79
- s.cv.unbind("<ButtonRelease-1>")
79
+ s.cv.unbind("<ButtonRelease-1>")
80
80
 
81
81
 
82
82
 
83
83
  def onpress(e):
84
84
 
85
- print("pendown {} {}".format(e.x, e.y))
85
+ print("pendown {} {}".format(e.x, e.y))
86
86
 
87
- s.cv.bind("<Motion>", onmotion)
87
+ s.cv.bind("<Motion>", onmotion)
88
88
 
89
- s.cv.bind("<ButtonRelease-1>", onrelease)
89
+ s.cv.bind("<ButtonRelease-1>", onrelease)
90
90
 
91
91
 
92
92
 

1

スペルミス修正(コードの実行には影響なし)

2020/03/26 17:01

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -52,7 +52,7 @@
52
52
 
53
53
  ```python
54
54
 
55
- # python record_motion.py > handwiring-apple.txt
55
+ # 実行方法: python record_motion.py > handwriting-apple.txt
56
56
 
57
57
  from turtle import *
58
58
 
@@ -110,7 +110,7 @@
110
110
 
111
111
 
112
112
 
113
- with open("handwiring-apple.txt", encoding="utf-8") as stream:
113
+ with open("handwriting-apple.txt", encoding="utf-8") as stream:
114
114
 
115
115
  write("Apple", None, "center", "serif 64 bold")
116
116