声明:主要是为了自己方便,所以把别人的教程搬到这里来,没有其他的意思.

如果有侵犯您的权益,请联系我QQ:3121922008

我会在第一时间妥善处理,抱歉.

还有其他的一些搜集的资源连接放在http://www.flask.pub

有兴趣的朋友不妨移驾一览.

Tkinter 编程:

TkInter是标准的Python GUI库。的Python与Tkinter的结合提供了一个快速和容易的方法来创建GUI应用程序。 Tkinter的提供了一个强大的面向对象的接口Tk的GUI工具包.

使用Tkinter创建一个GUI应用程序是一件容易的事。所有你需要做的是执行以下步骤:

  • 导入Tkinter模块.

  • 创建GUI应用程序的主窗口.

  • 添加上述部件之一或更多的GUI应用程序.

  • 进入主事件循环的由用户触发每个事件响应.

例子:

#!/usr/bin/python

import Tkinter
top = Tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()

这将创建一个下面的窗口:

Tkinter的部件:

Tkinter的提供各种控件,如按钮,标签和文本框,一个GUI应用程序中使用。这些控件通常被称为部件.

目前有15种Tkinter的部件。我们提出这些部件以及一个简短的介绍,在下面的表:

Operator Description
Button The Button widget is used to display buttons in your application.
Canvas The Canvas widget is used to draw shapes, such as lines, ovals, polygons, and rectangles, in your application.
Checkbutton The Checkbutton widget is used to display a number of options as checkboxes. The user can select multiple options at a time.
Entry The Entry widget is used to display a single-line text field for accepting values from a user.
Frame The Frame widget is used as a container widget to organize other widgets.
Label The Label widget is used to provide a single-line caption for other widgets. It can also contain images.
Listbox The Listbox widget is used to provide a list of options to a user.
Menubutton The Menubutton widget is used to display menus in your application.
Menu The Menu widget is used to provide various commands to a user. These commands are contained inside Menubutton.
Message The Message widget is used to display multiline text fields for accepting values from a user.
Radiobutton The Radiobutton widget is used to display a number of options as radio buttons. The user can select only one option at a time.
Scale The Scale widget is used to provide a slider widget.
Scrollbar The Scrollbar widget is used to add scrolling capability to various widgets, such as list boxes.
Text The Text widget is used to display text in multiple lines.
Toplevel The Toplevel widget is used to provide a separate window container.
Spinbox The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be used to select from a fixed number of values.
PanedWindow A PanedWindow is a container widget that may contain any number of panes, arranged horizontally or vertically.
LabelFrame A labelframe is a simple container widget. Its primary purpose is to act as a spacer or container for complex window layouts.
tkMessageBox This module is used to display message boxes in your applications.

标准属性:

让我们来看看如何他们的一些共同的属性。如大小,颜色和字体指定.

几何管理:

Tkinter的部件有特定几何形状的管理方法,整个小部件父控件区域组织的目的。 Tkinter的公开以下几何经理类:包装,网格,位置.

  • pack()方法 - 这个的几何管理器组织之前,将其放置在他们的父widget块部件.

  • grid()方法 - 这的几何管理器组织表状结构中的小部件的父部件.

  • place()方法 - 这个的几何管理器组织放置在一个特定的位置,在他们的父widget部件.

 
 

Python Tkinter编程的更多相关文章

  1. python Tkinter 编程

    Tkinter 是 Python 的标准 GUI 库.Python 使用 Tkinter 可以快速的创建 GUI 应用程序. 由于 Tkinter 是内置到 python 的安装包中.只要安装好 Py ...

  2. python界面Tkinter编程(tkMessageBox对话框使用)

    python界面Tkinter编程(tkMessageBox对话框使用)     转载 https://blog.csdn.net/m_buddy/article/details/80105154 1 ...

  3. Python: Tkinter、ttk编程之计算器

    起源: 研究Python UI编程,我偏喜欢其原生组件,于是学习Tkinter.ttk组件用法.找一计算器开源代码,略加修整,以为备忘.其界面如图所示: 1.源代码(Python 2.7): # en ...

  4. Python GUI编程(Tkinter) windows界面开发

    Python实现GUI简单的来说可以调用Tkinter库,这样一般的需求都可以实现,显示简单的windows窗口代码如下: python_gui.py 1 #!C:\Python27\python.e ...

  5. python GUI编程tkinter示例之目录树遍历工具

    摘录 python核心编程 本节我们将展示一个中级的tkinter应用实例,这个应用是一个目录树遍历工具:它会从当前目录开始,提供一个文件列表,双击列表中任意的其他目录,就会使得工具切换到新目录中,用 ...

  6. Python -- Gui编程 -- Tkinter的使用 -- 对话框消息框

    1.消息框 tkMessageBox.py import tkinter from tkinter import messagebox def cmd(): global n global butto ...

  7. python Tkinter接受键盘输入并保存文件

    最近想用python写个切换host的小工具,折腾了好几天,终于实现了第一步. 采用Tkinter编程,text控件接受输入,然后点击save按钮,保存内容到当前文件夹下,文件名为hostb,如下两张 ...

  8. Python GUI编程实践

    看完了<python编程实践>对Python的基本语法有了一定的了解,加上认识到python在图形用户界面和数据库支持方面快捷,遂决定动手实践一番. 因为是刚接触Python,对于基本的数 ...

  9. Python GUI编程各种实现的对比

    Python GUI编程各种实现的对比 从 Python 语言的诞生之日起,就有许多优秀的 GUI 工具集整合到 Python 当中,这些优秀的 GUI 工具集,使得 Python 也可以在图形界面编 ...

随机推荐

  1. python删除list中元素的三种方法

    a.pop(index):删除列表a中index处的值,并且返回这个值. del(a[index]):删除列表a中index处的值,无返回值. del中的index可以是切片,所以可以实现批量删除. ...

  2. (转) 从windows XP到10的微软官方操作系统虚拟机镜像,即下即用,不用安装

    原文地址: https://blog.csdn.net/tool321_com/article/details/50707512 最近在帮朋友安装虚拟机,遇到了这么一个东西,感觉比较不错,分享如下: ...

  3. linux中的网络基础

    ifconfig -a 查看所有网口ifconfig eth 查看具体网口 ifup ethoifdown etho 网卡配置文件/etc/sysconfig/networkk-scripts/ifc ...

  4. 个人博客网站 www.superzhang.site

    用django新建了一个博客网站,访问地址为www.superzhang.site.欢迎来逛逛.

  5. hessian 协议 版本 兼容

    环境 : 服务端:  hessian 4.0.38 , spring 4.3.6 ; spring文档指出spring4.0以上的版本只能使用hessian 4.0以上的版本 客户端: hessian ...

  6. HDU - 1142:A Walk Through the Forest (拓扑排序)

    Jimmy experiences a lot of stress at work these days, especially since his accident made working dif ...

  7. 《selenium2 python 自动化测试实战》(9)——切换窗口

    有时候我们点击按钮后页面会跳转到新的窗口,我们需要到新的窗口中去进行接下来的操作,这时候就需要切换窗口的操作,我们根据句柄(handle)来操作窗口之间的切换,看代码: # coding: utf-8 ...

  8. 接口测试框架——第六篇-读Excel封装方法

    谢谢@小麦苹果的提醒,才发现我借口测试少写了一个文件,今天给大家补上: common->service->excel_case_data.py # coding: utf-8 import ...

  9. Sprint第一个冲刺(第六天)

    一.Sprint介绍 今天我们完成了修改注册和登录直接用滚轮选择,主界面加入轮播图 . 实验截图: 主界面加入轮播图: 任务进度: 二.Sprint周期 看板: 燃尽图:

  10. elixir 调用erlang 代码

    备注:    项目比较简单,主要是elixir 混合erlang 代码,elixir 调用erlang 模块方法   1. 初始化项目   mix new erlangelixirdemo 项目结构如 ...