回答編集履歴
1
コード修正
test
CHANGED
@@ -132,6 +132,10 @@
|
|
132
132
|
|
133
133
|
|
134
134
|
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
135
139
|
import time
|
136
140
|
|
137
141
|
import threading
|
@@ -146,7 +150,7 @@
|
|
146
150
|
|
147
151
|
|
148
152
|
|
149
|
-
def
|
153
|
+
def worker():
|
150
154
|
|
151
155
|
global flag
|
152
156
|
|
@@ -196,69 +200,63 @@
|
|
196
200
|
|
197
201
|
|
198
202
|
|
199
|
-
|
200
|
-
|
201
|
-
logging.
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
if __name__ == '__main__':
|
260
|
-
|
261
|
-
main()
|
203
|
+
logging.basicConfig(
|
204
|
+
|
205
|
+
level=logging.DEBUG,
|
206
|
+
|
207
|
+
format="%(threadName)s %(message)s")
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
root = tk.Tk()
|
212
|
+
|
213
|
+
label = tk.Label(root)
|
214
|
+
|
215
|
+
label.pack()
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
thread = threading.Thread(target=worker)
|
220
|
+
|
221
|
+
thread.start()
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
def close():
|
226
|
+
|
227
|
+
global flag
|
228
|
+
|
229
|
+
flag = False
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
# スレッドの終了を待つブロッキング処理
|
234
|
+
|
235
|
+
logging.debug("thread join")
|
236
|
+
|
237
|
+
thread.join()
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
# スレッドが終了するまでここは実行されない
|
242
|
+
|
243
|
+
# thread.join により tkinter のイベントループは停止中
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
logging.debug("root destroy")
|
248
|
+
|
249
|
+
root.destroy()
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
root.protocol("WM_DELETE_WINDOW", close)
|
254
|
+
|
255
|
+
root.mainloop()
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
262
260
|
|
263
261
|
```
|
264
262
|
|