python学习笔记1——python 中 Tkinder 使用常见问题
来源:互联网 发布:mysql安装教程 编辑:程序博客网 时间:2024/06/03 11:21
python学习笔记1——python 中 Tkinder 使用常见问题
在使用Tkinder开发GUI时候需要import Tkinder,但是不同的版本的python使用上面有所区别,其中2.x和3.x中import就有所区别,相关的modules名称也有区别,使用时候需要加以注意,否则会出现错误!
python 2.x (本人安装的是2.7.12)中Tkinder import需要大写,如下:
import tkinter
或者
from tkinter import *
import tkinter
或者
from tkinter import *
以上两个版本的Tkinder Modules也有所不同,如下所示:
python 2.7.12 如下:
Other modules that provide Tk support include:
ScrolledText
- Text widget with a vertical scroll bar built in.
tkColorChooser
- Dialog to let the user choose a color.
tkCommonDialog
- Base class for the dialogs defined in the other modules listed here.
tkFileDialog
- Common dialogs to allow the user to specify a file to open or save.
tkFont
- Utilities to help work with fonts.
tkMessageBox
- Access to standard Tk dialog boxes.
tkSimpleDialog
- Basic dialogs and convenience functions.
Tkdnd
- Drag-and-drop support for
Tkinter
. This is experimental and should become deprecated when it is replaced with the Tk DND. turtle
- Turtle graphics in a Tk window.
Other modules that provide Tk support include:
tkinter.scrolledtext
- Text widget with a vertical scroll bar built in.
tkinter.colorchooser
- Dialog to let the user choose a color.
tkinter.commondialog
- Base class for the dialogs defined in the other modules listed here.
tkinter.filedialog
- Common dialogs to allow the user to specify a file to open or save.
tkinter.font
- Utilities to help work with fonts.
tkinter.messagebox
- Access to standard Tk dialog boxes.
tkinter.simpledialog
- Basic dialogs and convenience functions.
tkinter.dnd
- Drag-and-drop support for
tkinter
. This is experimental and should become deprecated when it is replaced with the Tk DND. turtle
- Turtle graphics in a Tk window
示例:
#_*_coding:utf-8_*_from Tkinter import *import tkSimpleDialog as dlimport tkMessageBox as mb# python 3.5 # from tkinter import *# import tkinter.simpledialog as dl# import tkinter.messagebox as mbroot = Tk()w = Label(root,text="Lable title")w.pack() #使其循环显示,而不是显示一次就消失了mb.showinfo("welcome","welcome to ktinter")guess = dl.askinteger("Number","Enter a number!")output = 'this is a output message'mb.showinfo("output",output)结果:
以上是python2.x和python3.x在Tkinder上的小小区别,使用时候需要注意,否则会报错!其它相关区别可以参考各个python版本对应的documentation!
0 0
- python学习笔记1——python 中 Tkinder 使用常见问题
- [Python]python学习笔记(二)——常见问题
- Python学习笔记——Python中使用Mysql
- [Python学习笔记]2——Python使用函数
- Python学习笔记【三】——《python基础教程》:: 使用字符串
- python学习笔记26(python中__name__的使用)
- python学习笔记28(python中pickle的使用)
- python学习笔记29(python中堆的使用)
- 【笔记】Python学习笔记 ——1
- Python开发中常见问题(python常见问题)
- python学习总结 常见问题
- Python学习笔记——Python开发中基本的语法1
- python 学习笔记——python globals()
- python中flask 常见问题
- Python学习笔记(—):初识python
- 新手使用python常见问题
- Python 使用技巧 常见问题
- Python学习笔记1——python的关键要素
- WebGIS中地图恢复初始位置及状态
- Java的封装
- 【Inno Setup】Gif插件2.1
- c# checked关键字
- 初步使用EventBus (一)
- python学习笔记1——python 中 Tkinder 使用常见问题
- LINUX分区、目录挂载
- Unity3D 快捷键技巧
- java图片等比例缩略显示在页面
- 怎么多了一个typename?
- 技术博客起源。
- Windows 2008R2上将VMware的虚拟机做成服务,实现开机自动启动虚拟机
- Fastboot一直在等待
- apache 配置域名+日志