1、 窗口  Tkinter.Tk()

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('南风丶轻语')
myWindow.geometry('400x500')
myWindow.mainloop()

  运行结果

2、 标签 Label   Tkinter.Label()

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('南风丶轻语')
myWindow.geometry('400x500') textVar = Tkinter.StringVar()
textVar.set('我是一个标签')
mylabel = Tkinter.Label(myWindow, bg='yellow', width=20, height=1,textvariable=textVar)
mylabel.pack() myWindow.mainloop()

  运行结果

3、 按钮 Tkinter.Button()

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('南风丶轻语')
myWindow.geometry('400x500') textVar = Tkinter.StringVar()
textVar.set('我是一个标签')
mylabel = Tkinter.Label(myWindow, bg='yellow', width=20, height=1,textvariable=textVar)
mylabel.pack() print type(textVar.get()) clickFlag = False
def clickEvet():
global clickFlag
if clickFlag == False:
textVar.set('我是被点击后的标签')
clickFlag = True
else:
textVar.set('我是一个标签')
clickFlag = False myButton = Tkinter.Button(myWindow, width=10, height=1,text='点击', command=clickEvet)
myButton.pack() myWindow.mainloop()

  运行结果

4、 输入框 Tkinter.Entry()

  备注 : 程序功能为点击按钮,标签显示 entry 中输入的内容

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('南风丶轻语')
myWindow.geometry('400x500') textVar = Tkinter.StringVar()
textVar.set('我是一个标签')
mylabel = Tkinter.Label(myWindow, bg='yellow', width=20, height=1,textvariable=textVar)
mylabel.pack() def clickEvet():
textVar.set(myEntry.get()) myButton = Tkinter.Button(myWindow, width=10, height=1,text='点击', command=clickEvet)
myButton.pack() myEntry = Tkinter.Entry(myWindow, width=20,)
myEntry.pack() myWindow.mainloop()

  运行结果

5、 文本框

  备注 : 实现功能为点击按钮,文本框插入数据(插入位置可以是鼠标位置,也可以是末尾,我们用两个按钮控制实现该效果)

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('南风丶轻语')
myWindow.geometry('400x500') myText = Tkinter.Text(myWindow, height=5, show=None)
myText.pack() def clickEvet1():
myText.insert('insert', '鼠标位置插入数据') def clickEvet2():
myText.insert('end', '末尾插入数据') myButton = Tkinter.Button(myWindow, width=10, height=1,text='鼠标插入', command=clickEvet1)
myButton.pack() myButton2 = Tkinter.Button(myWindow, width=10, height=1,text='末尾插入', command=clickEvet2)
myButton2.pack() myWindow.mainloop()

  运行结果

6、 listBox

  备注 : 点击按钮,实现文本框显示选中的 listBox 的内容

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('南风丶轻语')
myWindow.geometry('400x500') myText = Tkinter.Text(myWindow, height=5, show=None)
myText.pack() def clickEvet():
myText.insert('end', myListBox.get(myListBox.curselection())) myButton2 = Tkinter.Button(myWindow, width = 10, height = 1,text = '点击', command = clickEvet)
myButton2.pack() listBoxVar = Tkinter.StringVar()
listBoxVar.set((11, 22, 33, 'tan'))
myListBox = Tkinter.Listbox(myWindow, listvariable = listBoxVar)
myListBox.pack() myWindow.mainloop()

  运行结果

7、CheckBox

  备注:实现选中 CheckBox, 标签中显示选中内容

# -*- coding: UTF-8 -*-
import Tkinter myWindow = Tkinter.Tk()
myWindow.title('CheckButton Test Window')
myWindow.geometry('430x430') labelText = Tkinter.StringVar()
lable = Tkinter.Label(myWindow, textvariable=labelText, bg='yellow', width=30, height=1)
lable.pack(side='top') def chooseEvent():
if (chooseFirst.get() == 1) and (chooseSecond.get() == 0) and (chooseThird.get() == 0):
labelText.set('Tan')
elif (chooseFirst.get() == 0) and (chooseSecond.get() == 1) and (chooseThird.get() == 0):
labelText.set('Xiao')
elif (chooseFirst.get() == 0) and (chooseSecond.get() == 0) and (chooseThird.get() == 1):
labelText.set('Hui')
elif (chooseFirst.get() == 1) and (chooseSecond.get() == 1) and (chooseThird.get() == 0):
labelText.set('TanXiao')
elif (chooseFirst.get() == 1) and (chooseSecond.get() == 0) and (chooseThird.get() == 1):
labelText.set('TanHui')
elif (chooseFirst.get() == 0) and (chooseSecond.get() == 1) and (chooseThird.get() == 1):
labelText.set('XiaoHui')
elif (chooseFirst.get() == 1) and (chooseSecond.get() == 1) and (chooseThird.get() == 1):
labelText.set('TanXiaoHui')
else:
labelText.set('') chooseFirst = Tkinter.IntVar()
checkButton1 = Tkinter.Checkbutton(myWindow, text='Tan', variable=chooseFirst, onvalue=1, offvalue=0, command=chooseEvent)
checkButton1.place(x=200, y=22)
chooseSecond = Tkinter.IntVar()
checkButton2 = Tkinter.Checkbutton(myWindow, text='Xiao', variable=chooseSecond, onvalue=1, offvalue=0, command=chooseEvent)
checkButton2.place(x=200, y=44)
chooseThird = Tkinter.IntVar()
checkButton3 = Tkinter.Checkbutton(myWindow, text='Hui', variable=chooseThird, onvalue=1, offvalue=0, command=chooseEvent)
checkButton3.place(x=200, y=66) myWindow.mainloop()

  运行结果

Python Tkinter 图形组件介绍的更多相关文章

  1. python Tkinter图形用户编程简单学习(一)

    Events(事件) Events are given as strings, using a special event syntax:事件以字符串的方式给出,使用特殊的事件语法:<modif ...

  2. python的re模块一些方法 && Tkinter图形界面设计 && 终止python运行函数 && python读写文件 && python一旦给字符串赋值就不能单独改变某个字符,除非重新给变量赋值

    Tkinter图形界面设计见:https://www.cnblogs.com/pywjh/p/9527828.html#radiobutton 终止python运行函数: 采用sys.exit(0)正 ...

  3. Tkinter图形界面设计(GUI)

    [因为这是我第一个接触的GUI图形界面python库,现在也不用了,所以大多数内容都来自之前花 钱买的一些快速入门的内容,可以当作简单的知识点查询使用] 在此声明:内容来自微信公众号GitChat,付 ...

  4. 高效而稳定的企业级.NET Office 组件Spire(.NET组件介绍之二)

    在项目开发中,尤其是企业的业务系统中,对文档的操作是非常多的,有时几乎给人一种错觉的是”这个系统似乎就是专门操作文档的“.毕竟现在的很多办公中大都是在PC端操作文档等软件,在这些庞大而繁重的业务中,单 ...

  5. 一款开源免费的.NET文档操作组件DocX(.NET组件介绍之一)

    在目前的软件项目中,都会较多的使用到对文档的操作,用于记录和统计相关业务信息.由于系统自身提供了对文档的相关操作,所以在一定程度上极大的简化了软件使用者的工作量. 在.NET项目中如果用户提出了相关文 ...

  6. 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

  7. 数百个 HTML5 例子学习 HT 图形组件 – 3D 建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

  8. 数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇

    <数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇>一文让读者了解了 HT的 2D 拓扑图组件使用,本文将对 HT 的 3D 功能做个综合性的介绍,以便初学者可快速上手使用 HT ...

  9. 数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇

    HT 是啥:Everything you need to create cutting-edge 2D and 3D visualization. 这口号是当年心目中的产品方向,接着就朝这个方向慢慢打 ...

随机推荐

  1. AJ学IOS(39)UI之核心动画之CABasicAnimation(基础动画)

    AJ分享,必须精品 一.CABasicAnimation简介 CAPropertyAnimation的子类 属性解析: fromValue:keyPath相应属性的初始值 toValue:keyPat ...

  2. sql server临时删除/禁用非聚集索引并重新创建加回/启用的简便编程方法研究对比

    前言: 由于新型冠状病毒影响,博主(zhang502219048)在2020年1月份从广东广州工作地回到广东揭阳产业转移工业园磐东街道(镇里有阳美亚洲玉都.五金之乡,素以“金玉”闻名)老家后,还没过去 ...

  3. 计算机视觉中的对象检测,Python用几段代码就能实现

    目前计算机视觉(CV)与自然语言处理(NLP)及语音识别并列为人工智能三大热点方向,而计算机视觉中的对象检测(objectdetection)应用非常广泛,比如自动驾驶.视频监控.工业质检.医疗诊断等 ...

  4. Docker安装Redis并介绍漂亮的可视化客户端进行操作

    1 简介 Redis是使用ANSI C语言开发的基于Key-Value的高性能NoSQL数据库,在解决高并发.高可用等一系列问题中,它扮演着重要的角色.它的优势主要有: 速度快. 持久化. 原子性. ...

  5. Connections in Galaxy War ZOJ - 3261 (并查集)

    点权并查集的反向离线操作 题目大意:有n个stars,每一个都一定的“颜值”.然后stars与stars之间可以相连,query c表示再与c相连的stars中,颜值比c高的,stars的标号,如果有 ...

  6. Matlab学习-(2)

    1. 文件读取 在编写一个matlab项目时候,通常要导入很多不同格式的数据,下面我们来学习不同的导入函数.(1) 保存工作区MATLAB支持工作区的保存.用户可以将工作区或工作区中的变量以文件的形式 ...

  7. PHP函数:php_sapi_name

    php_sapi_name()  - 返回 web 服务器和 PHP 之间的接口类型. SAPI(Server Application Programming Interface)服务器应用程序编程接 ...

  8. P1464 Function

    Function 简   单   的   递   归 这道题一开始十分智障地用递归做,虽然知道没那么简单,但还是冒着送死的心态交了一遍,果然,如我所料 样例输入: 密密麻麻,几万行的样例输入 //:) ...

  9. 使用redis-dump与redis-load方式迁移redis数据库

    实际生产场景中,有可能会因为迁移机房或者更换物理机等原因需要在生产环境迁移redis数据.本文就来为大家介绍一下迁移redis数据的方法. 迁移redis数据一般有如下3种方式: 1.第三方工具red ...

  10. JACTF Web部分

    掘安团队的题目 平台已不运营 Web签到 发现请求URL为flag.php,但是会跳转到404.php页面,抓包发现有302重定向,查看响应包,flag经过base64编码,解码即可 Tips: 重定 ...