怎么解决name 'Tkinter' is not defined 问题
2010-11-26 09:07
344 查看
默认情况下这个Tkinter都是安装好的,可是就是运行出错,说name 'Tkinter' is not defined 郁闷
发现python的每个版本都在更新,有时语句都在变化
这个问题百度基本没找到,在google找到了答案(关键词搜索“error Tkinter is not defined”)
http://www.python-forum.org/pythonforum/viewtopic.php?f=4&t=16856
这上面的回答并不鼓励使用from Tkinter import * 说是失去命名空间同时导致名字冲突
引用上面的一段话:
The example below gives you a nice short namespace, used by a lot of programmers, particularly sine Python3 has gone to a Tkinter package name tkinter.
import os, getpass, time #意思就是在python3以前用
With Python3 you simple change one line
import os, getpass, time #python3使用
import tkinter as tk
root = tk.Tk()
import Tkinter as tk
root = tk.Tk()
按照上面的说的成功解决问题,第一个gui出来了
呵呵,这个解决了,后面的都快了
发现python的每个版本都在更新,有时语句都在变化
这个问题百度基本没找到,在google找到了答案(关键词搜索“error Tkinter is not defined”)
http://www.python-forum.org/pythonforum/viewtopic.php?f=4&t=16856
这上面的回答并不鼓励使用from Tkinter import * 说是失去命名空间同时导致名字冲突
引用上面的一段话:
The example below gives you a nice short namespace, used by a lot of programmers, particularly sine Python3 has gone to a Tkinter package name tkinter.
import os, getpass, time #意思就是在python3以前用
With Python3 you simple change one line
import os, getpass, time #python3使用
import tkinter as tk
root = tk.Tk()
import Tkinter as tk
root = tk.Tk()
按照上面的说的成功解决问题,第一个gui出来了
#from tkinter import * #第一步 #第二步,创建一个顶层窗口对象,来容纳整个GUI程序 #在您的顶层窗口的对象上创建所有的GUI模块 #把这些GUI模块与底层程序代码想连接 import os, getpass, time import tkinter as tk root = tk.Tk() #top=Tkinter.Tk()#创建一个顶层窗口对象 label=tk.Label(root,text='hell world') label.pack() tk.mainloop()#进入主事件循环
呵呵,这个解决了,后面的都快了
相关文章推荐
- NLTK使用中NameError: name 'FreqDist' is not defined问题解决
- 怎么解决Excel.ApplicationClass' cannot be embedded问题?
- ubuntu中undefined reference to `__stack_chk_fail_local\'问题怎么解决
- Nested exception: The entity name must immediately follow the '&' in the entity reference.问题的解决
- Unknown type name 'class'; did you mean 'Class'? 问题的解决
- 解决数据库 data too long for column 'name' at row 1的问题
- apache php $_SERVER['SERVER_NAME']没有保存端口号的问题(解决)
- swift怎么解决错误提示 'required' initializer 'init(coder:)' must be...这个问题
- 真机调试出问题“Could not launch 'app name'”,No such file or directory 的bug解决
- GEF,EMF,RCP,Eclipse's plugin的几个问题(5) RCP Navigator View project name 为空解决办法
- Unknown type name 'NSString' 问题已解决
- MySQL字符集 GBK、GB2312、UTF8区别 解决 MYSQL中文乱码问题以及error 1406:data too long for column 'name' at row 1
- 解决MyEclipse中tomcat出现的小问题:JDK Name, 以及Can't load AMD 64-bit .dll on a IA 32-bit platform
- 运行ase的sybase central 时提示错误unable to load language dll 'scsslgzh',怎么解决这个问题,
- cocoa Unknown type name 'class'; did you mean 'Class'? 问题的解决
- ERROR 1045 (28000): Access denied for user 'root'@'local 问题解决方案
- Node.js Cannot find module 'xxx' 问题解决
- 解决Unable to resolve target 'android-17'问题
- error C2504: 'IDXEffect' : base class 这个怎么解决?
- 对于 error C2065: 'GL_COMBINE_ARB' : undeclared identifier 问题的解决