回答編集履歴
2
補足
test
CHANGED
@@ -28,7 +28,19 @@
|
|
28
28
|
|
29
29
|
参考情報:[The Tkinter PhotoImage Class](http://effbot.org/tkinterbook/photoimage.htm)
|
30
30
|
|
31
|
+
> Note: When a PhotoImage object is garbage-collected by Python (e.g. when you return from a function which stored an image in a local variable), the image is cleared even if it’s being displayed by a Tkinter widget.
|
31
32
|
|
33
|
+
|
34
|
+
|
35
|
+
> To avoid this, the program must keep an extra reference to the image object. A simple way to do this is to assign the image to a widget attribute, like this:
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
> label = Label(image=photo)
|
40
|
+
|
41
|
+
> label.image = photo # keep a reference!
|
42
|
+
|
43
|
+
> label.pack()
|
32
44
|
|
33
45
|
|
34
46
|
|
1
追記
test
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
> _tkinter.TclError: unknown option "-file"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
グーグル翻訳
|
6
|
+
|
7
|
+
_tkinter.TclError:不明なオプション "-file"
|
8
|
+
|
9
|
+
|
10
|
+
|
1
11
|
```diff
|
2
12
|
|
3
13
|
-canvas.itemconfigure(c0,file = tmp_img)#コメントアウトしないとエラーが出て画面が出てこない
|
@@ -8,13 +18,17 @@
|
|
8
18
|
|
9
19
|
|
10
20
|
|
11
|
-
あとcanvas側に参照を持たないとGC(GarbageCollection)で画像が消えます。
|
21
|
+
あと`canvas`側に`PhotoImage`の参照を持たないとGC(`GarbageCollection`)で画像が消えます。
|
12
22
|
|
13
23
|
```Python
|
14
24
|
|
15
25
|
canvas.photo = tmp_img
|
16
26
|
|
17
27
|
```
|
28
|
+
|
29
|
+
参考情報:[The Tkinter PhotoImage Class](http://effbot.org/tkinterbook/photoimage.htm)
|
30
|
+
|
31
|
+
|
18
32
|
|
19
33
|
|
20
34
|
|
@@ -52,7 +66,7 @@
|
|
52
66
|
|
53
67
|
def change_flag():
|
54
68
|
|
55
|
-
# ※Popenはプロセス標準入出力をcloseしないとハンドルリークするかもです。
|
69
|
+
# ※Popenはプロセスの標準入出力をcloseしないとハンドルリークするかもです。
|
56
70
|
|
57
71
|
# もし長時間(5時間)動作するなら、subprocess.callの方を使ってくださいな。
|
58
72
|
|