tkinter entry框第一节
Posted uxiuxi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tkinter entry框第一节相关的知识,希望对你有一定的参考价值。
>>> from tkinter import *
>>> from tkinter import ttk
>>> root=Tk()
>>> entry=ttk.Entry(root,width=30) #character 最多可以填30个字符串。 中文的好想不对
>>> entry.pack() #排版
>>> entry.get() #你手动在框子里面敲你好。 他就获取他的value为你好!
‘你好!‘
>>> entry.delete(0,2) #删除第0到第二个字符。
>>> entry.get()
‘!‘
>>> entry.delete(0,END) #删除到底
>>> entry.insert(0,"Enter Your Password") #通过脚本输入
>>> entry.config(show="*") #设置输入时候一个字符对应一个星号,比如输密码
>>> entry.get()
‘sdfdsf‘
>>> entry.state([‘disabled‘]) #让框子无法输入内容
(‘!disabled‘,)
>>> entry.state([‘!disabled‘])
(‘disabled‘,)
>>> entry.state([‘readonly‘])
(‘!readonly‘,)
>>> entry.staet([‘!readonly‘]) #只许读,不许复制
Traceback (most recent call last):
File "<pyshell#175>", line 1, in <module>
entry.staet([‘!readonly‘])
AttributeError: ‘Entry‘ object has no attribute ‘staet‘
>>> entry.state([‘!readonly‘])
(‘readonly‘,)
>>> entry.config(show)
Traceback (most recent call last):
File "<pyshell#177>", line 1, in <module>
entry.config(show)
NameError: name ‘show‘ is not defined
>>> entry.config(show=)
SyntaxError: invalid syntax
>>> entry.config(show)
Traceback (most recent call last):
File "<pyshell#179>", line 1, in <module>
entry.config(show)
NameError: name ‘show‘ is not defined
>>> entry.config()
{‘cursor‘: (‘cursor‘, ‘cursor‘, ‘Cursor‘, ‘‘, <cursor object: ‘ibeam‘>), ‘show‘: (‘show‘, ‘show‘, ‘Show‘, ‘‘, ‘*‘), ‘takefocus‘: (‘takefocus‘, ‘takeFocus‘, ‘TakeFocus‘, ‘ttk::takefocus‘, ‘ttk::takefocus‘), ‘state‘: (‘state‘, ‘state‘, ‘State‘, <index object: ‘normal‘>, <index object: ‘normal‘>), ‘validatecommand‘: (‘validatecommand‘, ‘validateCommand‘, ‘ValidateCommand‘, ‘‘, ‘‘), ‘invalidcommand‘: (‘invalidcommand‘, ‘invalidCommand‘, ‘InvalidCommand‘, ‘‘, ‘‘), ‘width‘: (‘width‘, ‘width‘, ‘Width‘, 20, 30), ‘font‘: (‘font‘, ‘font‘, ‘Font‘, <font object: ‘TkTextFont‘>, <font object: ‘TkTextFont‘>), ‘xscrollcommand‘: (‘xscrollcommand‘, ‘xScrollCommand‘, ‘ScrollCommand‘, ‘‘, ‘‘), ‘foreground‘: (‘foreground‘, ‘textColor‘, ‘TextColor‘, ‘‘, ‘‘), ‘textvariable‘: (‘textvariable‘, ‘textVariable‘, ‘Variable‘, ‘‘, ‘‘), ‘style‘: (‘style‘, ‘style‘, ‘Style‘, ‘‘, ‘‘), ‘exportselection‘: (‘exportselection‘, ‘exportSelection‘, ‘ExportSelection‘, 1, 1), ‘justify‘: (‘justify‘, ‘justify‘, ‘Justify‘, <index object: ‘left‘>, ‘left‘), ‘class‘: (‘class‘, ‘‘, ‘‘, ‘‘, ‘‘), ‘background‘: (‘background‘, ‘windowColor‘, ‘WindowColor‘, ‘‘, ‘‘), ‘validate‘: (‘validate‘, ‘validate‘, ‘Validate‘, <index object: ‘none‘>, ‘none‘)}
>>> entry.config(show=‘Show‘)
>>> entry.config(show=‘show‘)
>>> entry.config(show=‘!*‘)
>>> entry.config(show=‘‘)
>>> entry.state()
()
>>> entry.instate([‘readonly‘])
False
>>> entry.state([‘readonly‘])
(‘!readonly‘,)
>>> entry.state([‘readonly‘])
()
>>> entry.instate([‘readonly‘])
True
>>>
以上是关于tkinter entry框第一节的主要内容,如果未能解决你的问题,请参考以下文章