Python2.7.3 Tkinter Entry(文本框) 说明
Python学习记录--关于Tkinter Entry(文本框)的选项、方法说明,以及一些示例。
属性(Options)
- background(bg)
- borderwidth(bd)
- cursor
- exportselection
- font
- foreground(fg)
- highlightbackground
- highlightcolor
- highlightthickness
- insertbackground
- insertborderwidth
- insertofftime
- insertontime
- insertwidth
- justify
- relief
- selectbackground
- selectborderwidth
- selectforeground
- show
- state
- takefocus
- textvariable
- width
- xscrollcommand
background(bg)
- Type: color
- 说明:文本框的背景颜色
#示例 from Tkinter import *top = Tk()text = Entry(top, background = 'red') text.pack()mainloop()
borderwidth(bd)
- Type: distance
- 说明:文本框边框宽度
#示例 text = Entry(top, borderwidth = 3)
cursor
- Type: cursor
- 待定
exportselection
- Type: flag
- 待定
font
- Type: font
- 说明:文字字体。值是一个元祖,font = ('字体','字号','粗细')
#示例 text = Entry(top, font = ('Helvetica', '14', 'bold')
foreground
- Type: color
- 说明:文字颜色。值为颜色或为颜色代码,如:'red','#ff0000'
#示例 text = Entry(top, foreground = 'red') #正确 text = Entry(top, foreground = '#ff0000') #正确 text = Entry(top, foreground = 'ff0000') #错误,必须加上#号
highlightbackground
- Type: color
- 说明:文本框高亮边框颜色,当文本框未获取焦点时显示
- 条件:highlightthickness设置有值
#示例 text = Entry(top, highlightbackground = 'red', hightlightthickness = 1)
highlightcolor
- Type: color
- 说明:文本框高亮边框颜色,当文本框获取焦点时显示
- 条件:highlightthickness设置有值
#示例 text = Entry(top, highlightcolor = 'red', hightlightthickness = 1)
highlightthickness
- Type: distance
- 说明:文本框高亮边框宽度。(官网上说有默认值1或2,但如果不设置,实际上没有值,可能和操作系统有关系)
#示例 text = Entry(top, highlightcolor = 'red', hightlightthickness = 1)
insertbackground
- Type: color
- 说明:文本框光标的颜色
#示例 text = Entry(top, insertbackground = 'red')
insertborderwidth
- Type: distance
- 说明:文本框光标的宽度。(有问题,官网未有说明,待定)
#示例 text = Entry(top, insertborderwidth = 3)
insertofftime
- Type: int
- 说明:文本框光标闪烁时,消失持续时间,单位:毫秒
#示例 text = Entry(top, insertofftime = 50)
insertontime
- Type: int
- 说明:文本框光标闪烁时,显示持续时间,单位:毫秒
#示例 text = Entry(top, insertontime = 50)
insertwidth
- Type: int
- 说明:文本框光标宽度
#示例 text = Entry(top, insertwidth = 3)
justify
- Type: const
- 待定
relief
- Type: const
- 说明:文本框风格,如凹陷、凸起,值有:flat/sunken/raised/groove/ridge
#示例 text = Entry(top, relief = 'sunken')
selectbackground
- Type: color
- 说明:选中文字的背景颜色
#示例 text = Entry(top, selectbackground = 'red') text = Entry(top, selectbackground = '#ff0000')
selectborderwidth
- Type: int
- 说明:选中文字的背景边框宽度
#示例 text = Entry(top, selectborderwidth = 3)
selectforeground
- Type: color
- 说明:选中文字的颜色
#示例 text = Entry(top, selectforeground = 'red') text = Entry(top, selectforeground = '#ff0000')
show
- Type: character
- 说明:指定文本框内容显示为字符,值随意,满足字符即可。如密码可以将值设为*
#示例 text = Entry(top, show = '*')
state
- Type: const
- 说明:文框状态,分为只读和可写,值为:normal/disabled
#示例 text = Entry(top, state = 'normal') #可操作 text = Entry(top, state = 'disabled') #不可操作
takefocus
- Type: flag
- 说明:是否能用TAB键来获取焦点,默认是可以获得
#示例 待定
textvariable
- Type: variable
- 说明:文本框的值,是一个StringVar()对象
#示例 default_value = StringVar() default_value.set('This is a default value') text = Entry(top, textvariable = default_value)
width
- Type: int
- 说明:文本框宽度
#示例 text = Entry(top, width = 50)
xscrollcommand
- Type: callback
- 说明:回调函数
#示例 def callback():#codetext = Entry(top, command = callback)
方法(Methods)
- insert
- delete
- icursor
- get
- index
- selection_adjust, select_adjust
- selection_clear, select_clear
- selection_from, select_from
- selection_present, select_present
- selection_range, select_range
- selection_to, select_to
- scan_mark
- scan_dragto
- xview
- xview_moveto, xview_scroll
insert(index, text)
向文本框中插入值,index:插入位置,text:插入值
#示例 text.insert(0, '内容一') #在文本框开始位置插入“内容一” text.insert(10, '内容二') #在文本框第10个索引位置插入“内容二” text.insert(END, '内容三') #在文本框末尾插入“内容三”
delete(index), delete(from, to)
删除文本框里直接位置值
#示例 text.delete(10) #删除索引值为10的值 text.delete(10, 20) #删除索引值从10到20之前的值 text.insert(0, END) #删除所有值
icursor(index)
将光标移动到指定索引位置,只有当文框获取焦点后成立
#示例 text.icursor(10) #移动光标到索引为10的位置
get()
获取文件框的值
#示例 text.get() #返回文本框的值
index(index)
返回指定的索引值
#示例 text.index(2)
selection_adjust(index), select_adjust(index)
选中指定索引和光标所在位置之前的值
#示例 text.selection_adjust(2) #选中索引为2和光标所有位置之前的所有值
selection_clear(), select_clear()
清空文本框
#示例 text.selection_clear()
selection_from(index), select_from(index)
待定
selection_range(start, end), select_range(start, end)
选中指定索引之前的值,start必须比end小
#示例 text.selection_range(2, 10) #选中索引为2和10之前的所有值
selection_to(index), select_to(index)
选中指定索引与光标之间的值(感觉和selection_adjust差不多)
#示例 text.selection_to(2) #选中索引为2和所光标所在位置之前的值
scan_mark(x)
待定
scan_dragto(x)
待定
xview(x)
待定
转载于:https://www.cnblogs.com/monsteryang/p/6575877.html
Python2.7.3 Tkinter Entry(文本框) 说明相关推荐
- python tkinter 文本框全选_Python Tkinter Entry(文本框)
Python学习记录--关于Tkinter Entry(文本框)的选项.方法说明,以及一些示例. 属性(Options) background(bg) Type: color 说明:文本框的背景颜色 ...
- python entry高度_Python2.7.3 Tkinter Entry(文本框) 说明
属性(Options) background(bg) Type: color 说明:文本框的背景颜色 #示例 from Tkinter import * top = Tk() text = Entry ...
- Python使用tkinter库制作带有Laber标签、Entry文本框、Progressbar进度条、text日志框等元素的GUI操作界面
本文通过实例介绍Python的tkinter库的title.iconbitmap.geometry.attributes.grid等类的功能,并制作带有Laber标签.Entry文本框.Progres ...
- python tkinter输入框_python TKinter获取文本框内容的方法
python TKinter获取文本框内容的方法 更新时间:2018年10月11日 11:36:08 作者:biubiuzzz 今天小编就为大家分享一篇python TKinter获取文本框内容的方法 ...
- python输出文本框_python TKinter获取文本框内容的方法
python TKinter获取文本框内容的方法 如下所示: #coding:utf-8 import urllib,urllib2 import Tkinter #导入TKinter模块 ytm=T ...
- python输出文本框_让tkinter在文本框中显示输出
我试图创建一个小的GUI,当用户在文本框中输入一个数字时,它显示(作为标签)是否是素数.让tkinter在文本框中显示输出 我目前"工作"的代码(因为没有错误显示),但标签不会改变 ...
- tkinter向文本框里加内容_给tkinter文本框添加右键菜单
给tkinter文本框添加右键菜单 需求:直接右键点击使用tkinter创建的文本框是不会弹出菜单的.我们需要实现右键点击tkinter框架下的Entry对象.Text对象后弹出右键菜单可复制.粘贴和 ...
- python Entry 文本框只能输入数字或限定数字显示
先给大家看代码,表示对大家急切想法的尊敬,如果你着急用,直接拿去,不明白的话回来再看看后续,我争取讲的明白,我也是一个小白,我只能按照我自己的意思去写,如果有补充或者修改请联系我,也请不要完全相信我, ...
- Python GUI设计——Entry文本框、文字区域Text
目录 1.Entry 1.1基本概念 1.2使用show参数隐藏输入的字符 1.3Entry的get()方法 1.4Entry的insert()方法 1.5Entry的delete()方法 1.6计算 ...
最新文章
- 剑指offer_第18题_二叉树的镜像_Python
- MyBatis插件使用--分页插件与性能拦截器
- java excel导入前台_java上传excel表格并读取数据返回到前台
- html语言难不难学,Web前端开发难学吗?
- 需求与范围驾驭深刻反省总结
- CodeForces - 660C Hard Process
- 测试范围不统一,引发的冲突问题
- 中国移动公布5G核心网大单 全面加快5G网络部署
- linux操作命令 mongo_MongoDB常用操作命令整理
- 使用MyBatis select数据库查出有数据 但返回对象为null时的解决办法
- Eviews10.0下载与安装
- 冰桶挑战”的火爆程度与朋友圈?
- TVP5147调试经验
- 阿斯利康联手多家诊断公司,共建肺癌诊疗生态圈
- python爬虫百度地图_零基础掌握百度地图兴趣点获取POI爬虫(python语言爬取)(基础篇)...
- The Willpower Instinct
- HFDS 内部工作机制
- 【新书推荐】【2019】基于Kronecker积波束形成的阵列处理
- PyTorch-5 自定义 Datasets, DataLoaders 和 Transforms
- 解决垃圾小米文件管理器删除文件后存储空间不变,内存不变大,不释放空间。解决方法:点图中那个结束运行,再重新打开软件(直接滑动退出后台无效果)
热门文章
- ffmpeg系列-编译
- Media Player Classic - HC 源代码分析 7:详细信息选项卡(CPPageFileInfoDetails)
- c语言,成绩输出直方图,编写一个程序,打印输入中单词长度的直方图
- js中常用方法以及document.readyState 判断页面是否加载完成 complete和interactive
- c语言界面飞机图形代码,求个用最简单的的代码来实现图形界面…
- java实现Beta函数
- 升级到jdk1.8后 sun/io/CharToByteConverter错误及处理
- linux用cmake编译,CMake使用简介(forLinux)
- 第六章节 三层架构(一. 三层架构的概述)
- [leetcode]190. 颠倒二进制位