Tkinter有用吗?

2024-05-14 23:22:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经从:http://wiki.python.org/moin/TkInter安装了python3.2。在

第三步-Tkinter有效吗?在

在Python提示符下尝试以下命令:

Tkinter._test() # note underscore in _test. Also, if you are using Python 3.1, try tkinter._test() instead. This should pop up a small window with two buttons.

>>> Tkinter._test
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    Tkinter._test
NameError: name 'Tkinter' is not defined

>>> tkinter._test
<function _test at 0x00000000028FD2C8>

但是,没有“带2个按钮的窗口”。 思想?在


Tags: inorgtest命令httpiftkinterwiki
3条回答

在示例代码中,您在测试后忘记了包括括号。Test实际上是一个函数,因此它需要括号:

tkinter._test()

使用:

tkinter._test()

请注意括号-它们在调用函数时是必需的。如果你用参数调用一个函数。在

要测试模块是否已正确导入(这适用于任何模块),请尝试:

^{pr2}$

例如:

import tkinter
print(tkinter)

运行tkinter._test()。注意括号。在

相关问题 更多 >

    热门问题