m0_57901298 2021-06-29 10:59 采纳率: 58.3%
浏览 477
已结题

module '_tkinter' has no attribute 'tkapp'

我对self.tk.call感到好奇,于是写了一个返回self.tk和self.tk.call的方法.

import tkinter as tk
class TEST(tk.Button):
	def _TKOBJ(self):
		return self.tk
	def _TKCALLOBJ(self):
		return self.tk.call

结果

>>> t = _t.TEST()
>>> t._TKCALLOBJ()
<built-in method call of _tkinter.tkapp object at 0x0000000002BBB6B0>
>>> t._TKOBJ()
<_tkinter.tkapp object at 0x0000000002BBB6B0>
>>> _tk.tkapp
Traceback (most recent call last):
  File "<pyshell#34>", line 1, in <module>
    _tk.tkapp
AttributeError: module '_tkinter' has no attribute 'tkapp'
>>> _tk.tkapp.call
Traceback (most recent call last):
  File "<pyshell#35>", line 1, in <module>
    _tk.tkapp.call
AttributeError: module '_tkinter' has no attribute 'tkapp'
>>> _tk.call
Traceback (most recent call last):
  File "<pyshell#36>", line 1, in <module>
    _tk.call
AttributeError: module '_tkinter' has no attribute 'call'

为什么?

  • 写回答

2条回答 默认 最新

  • m0_57901298 2021-08-26 14:37
    关注

    tkinter_init_.py 2261行
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月3日
  • 已采纳回答 8月26日