1. 程式人生 > >tkinter entry框第一節

tkinter entry框第一節

del width shell ace mman 密碼 conf fin mos

>>> 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框第一節