teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

修正

2021/02/18 14:00

投稿

goki_gottan
goki_gottan

スコア168

title CHANGED
File without changes
body CHANGED
@@ -5,4 +5,37 @@
5
5
  そこで、
6
6
  while trueを設け、例外処理で、after_cancelをしてエラーとなればafterが消えたと判断し、whileを抜けたとしているのですが、やはり、極たまに起きます。
7
7
 
8
- 強制的に削除できないものでしょうか?
8
+ 強制的に削除できないものでしょうか?
9
+
10
+ ```
11
+ def t1()
12
+     global after_id
13
+
14
+ def repeat_func():
15
+ global after_id
16
+
17
+        canvasの色変更
18
+
19
+ frame1.update
20
+ canvas.update_idletasks() # 描画更新
21
+
22
+ after_id = frame1.after(500, repeat_func)
23
+
24
+ return
25
+
26
+     repeat_func
27
+
28
+ for a in b:
29
+ ある処理
30
+
31
+     frame1.after_cancel(after_id)
32
+ after_id=None      
33
+
34
+ thread3=threading.Thread(target=t1)
35
+ thread3.start()
36
+ ```
37
+
38
+ スレッドを使用しているのは、tkinterGUIを使用して、
39
+ for文を使用し、その結果をcanvasで色付けしているためです。
40
+
41
+ このスレッドが悪さしているということはないでしょうか。