2
delattr
組み込み関数を使用して、Tkinterウィンドウから派生したクラスインスタンスからメソッドを削除しようとしています。しかし、私は次のエラーが発生します。私は間違って何をしていますか?Tkinterウィンドウからメソッド/属性を削除できないのはなぜですか?
エラー:
AttributeError: Class instance has no attribute 'wm_title'
例:
import Tkinter as tk
class Class (tk.Tk) :
def __init__ (self) :
tk.Tk.__init__(self)
# The method is clearly there, seeing as this works.
self.wm_title('')
# This raises an AttributeError.
delattr(self, 'wm_title')
c = Class()
c.mainloop()