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

回答編集履歴

2

リソースの解放等の後始末を自分で明示的に記述

2021/04/10 14:11

投稿

sobagome
sobagome

スコア9

answer CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import tkinter as tk
5
5
  import threading
6
+ import gc
6
7
 
7
8
  class MainWin(tk.Frame):
8
9
  def __init__(self,master):
@@ -52,7 +53,6 @@
52
53
  root.protocol("WM_DELETE_WINDOW", app.cleanup)
53
54
  app.mainloop()
54
55
  root = app = None
55
- import gc
56
56
  gc.collect()
57
57
 
58
58
  if __name__ == "__main__":

1

リソースの解放等の後始末を自分で明示的に記述

2021/04/10 14:11

投稿

sobagome
sobagome

スコア9

answer CHANGED
@@ -51,6 +51,9 @@
51
51
  app = MainWin(master=root)
52
52
  root.protocol("WM_DELETE_WINDOW", app.cleanup)
53
53
  app.mainloop()
54
+ root = app = None
55
+ import gc
56
+ gc.collect()
54
57
 
55
58
  if __name__ == "__main__":
56
59
  main()