2011-05-01 51 views
1

我已经安装了Python 3.2:http://wiki.python.org/moin/TkInterTkinter的工作?

第3步 - 做Tkinter的工作?

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

Tkinter._test()#注意在_test下划线。另外,如果您使用的是Python 3.1,请尝试tkinter._test()。 这应该弹出一个有两个按钮的小窗口。

>>> 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个按钮'。 想法?

回答

6

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

+0

糟糕!多么尴尬!可惜他们无法修复wordwrap,因此()与函数位于同一行。 – verstapp 2011-05-01 08:36:25

0

用途:

tkinter._test() 

注括号 - 调用函数时,他们是势在必行。这是如果你正在调用带参数的函数。

为了测试一个模块导入正确(这适用于任何模块)尝试:

import [module name here] 
print([module name here]) 

一个例子是:

​​