【坑】Tkinter ‘NoneType‘ object has no attribute ‘destroy‘
用Tkinter的元件時遇到,無法摧毀/隱藏/放置的情況
AttributeError: ‘NoneType’ object has no attribute ‘place’
AttributeError: ‘NoneType’ object has no attribute ‘place_forget’
AttributeError: ‘NoneType’ object has no attribute ‘destroy’
出現這個錯誤的原因,舉個例子:
# 寫法一:c = a().b()式寫法
# 由於 pack(), place(), grid() 的返回值是'None'
# 這樣 self.subBar 得到的返回值是 'None',
# 而不是我們希望的 a 的返回值
# 執行到 'destroy()'的時候,就會出以下錯誤
# AttributeError: 'NoneType' object has no attribute 'destroy'
self.subBar = Frame(self.backGround,bg='#FFFFFF').place(x=10,y=75,width=100,height=5)
.....
.....
self.subBar.destroy()
# 寫法二:
# c = a.()
# c.b()
# 這樣 c 得到的是 a 的返回值,
# 後面的 'destroy()' 就可以正常執行了
self.subBar = Frame(self.backGround,bg='#FFFFFF')
self.subBar.place(x=10,y=75,width=100,height=5)
.....
.....
self.subBar.destroy()
忽略了 place() 的賦值。。。
相關文章
- 問題解決:AttributeError: ‘NoneType‘ object has no attribute ‘append‘ErrorNoneObjectAPP
- Traceback (most recent call last): File "AttributeError: 'NoneType' object has no attribute 'group'ASTErrorNoneObject
- Process object has no attribute '_popen'Object
- ‘dict‘ object has no attribute ‘iteritems‘Object
- AttributeError: 'dict' object has no attribute 'has_key'ErrorObject
- ‘FirewallD‘ object has no attribute ‘path‘ 、‘fw‘、is not registeredObject
- AttributeError: 'module' object has no attribute 'lock'ErrorObject
- AttributeError: 'Settings' object has no attribute 'HBase'ErrorObject
- python去掉excel空格和換行,報錯'int' object has no attribute 'strip'PythonExcelObject
- Rasa init報錯:AttributeError: type object 'Callable' has no attribute '_abc_registry'ErrorObject
- python-unittest 框架利用 PageObject 設計模式在 BasePage 類中呼叫不到 send_keys 方法,執行報錯'NoneType' object has no attribute 'send_keys'Python框架Object設計模式None
- Uncaught TypeError: Object [object Object] has no method 'xxx'ErrorObject
- module ‘h5py‘ has no attribute ‘File‘H5
- AttributeError: module ‘requests‘ has no attribute ‘_version_‘Error
- module ‘tensorflow‘ has no attribute ‘get_default_graph‘
- Uncaught TypeError: Object # has no method 'load'ErrorObject
- 解決pycharm問題:module 'pip' has no attribute 'main'PyCharmAI
- [轉]成功解決AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘?Error
- 1_使用face_recognition模組:錯誤AttributeError:'PngStream' object has no attribute 'chunk fcWp'(20190223)ErrorObject
- zt_powerdesigner_'find in diagram' 後彈出'the object has no symbol'ObjectSymbol
- AttributeError: module...ops‘ has no attribute ‘_TensorLike‘, ValueError: `updates` argument..eagerError
- python3 tkinter報錯:_tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by gridPythonErrorIDE
- 骷髏坑人小技巧1[python]:坑爹遊戲[tkinter]Python遊戲
- org.apache.coyote.AbstractProtocol.destroy Failed to destroy end point associated with ProtocolHandlApacheProtocolAI
- AttributeError: module ‘tensorflow._api.v1.nn.rnn_cell‘ has no attribute ‘InputProjectionWrapper‘ErrorAPIRNNProjectAPP
- 【Error】AttributeError: module ‘scipy.misc‘ has no attribute ‘logsumexp‘ 的解決辦法Error
- Invalid configuration object webpack dev server has been initialisedObjectWebdevServer
- AttributeError: module‘ tensorflow_core._api.v2. train‘ has no attribute‘ AdamOptimizer‘ErrorAPIAI
- clipboard.destroy報錯
- Oracle RAC crsd日誌-0Resource ora!dbtest2!vip has incomplete attribute setOracle
- tkinter
- Syntax Error: ValidationError: Invalid options object. Stylus Loader has been initialized using anErrorObjectZed
- import tkinter與from tkinter import *的區別Import
- HDU 4940 Destroy Transportation system(圖論)圖論
- pytorch 踩坑,TypeError: expected seqence object with len>_0 or a single integer_typeerror: expected sequence object with len __ 0PyTorchErrorObject
- jQuery [attribute]jQuery
- Attribute Checks
- 求助:TypeError: unsupported format string passed to NoneType.__format__ErrorORMNone