Python學習記錄--關於Tkinter Entry(文本框)的選項、方法說明,以及一些示例。html
#示例 from Tkinter import * top = Tk() text = Entry(top, background = 'red') text.pack() mainloop()
#示例 text = Entry(top, borderwidth = 3)
#示例 text = Entry(top, font = ('Helvetica', '14', 'bold')
#示例 text = Entry(top, foreground = 'red') #正確 text = Entry(top, foreground = '#ff0000') #正確 text = Entry(top, foreground = 'ff0000') #錯誤,必須加上#號
#示例 text = Entry(top, highlightbackground = 'red', hightlightthickness = 1)
#示例 text = Entry(top, highlightcolor = 'red', hightlightthickness = 1)
#示例 text = Entry(top, highlightcolor = 'red', hightlightthickness = 1)
#示例 text = Entry(top, insertbackground = 'red')
#示例 text = Entry(top, insertborderwidth = 3)
#示例 text = Entry(top, insertofftime = 50)
#示例 text = Entry(top, insertontime = 50)
#示例 text = Entry(top, insertwidth = 3)
#示例 text = Entry(top, relief = 'sunken')
#示例 text = Entry(top, selectbackground = 'red') text = Entry(top, selectbackground = '#ff0000')
#示例 text = Entry(top, selectborderwidth = 3)
#示例 text = Entry(top, selectforeground = 'red') text = Entry(top, selectforeground = '#ff0000')
#示例 text = Entry(top, show = '*')
#示例 text = Entry(top, state = 'normal') #可操做 text = Entry(top, state = 'disabled') #不可操做
#示例 待定
#示例 default_value = StringVar() default_value.set('This is a default value') text = Entry(top, textvariable = default_value)
#示例 text = Entry(top, width = 50)
#示例 def callback(): #code text = Entry(top, command = callback)
向文本框中插入值,index:插入位置,text:插入值函數
#示例 text.insert(0, '內容一') #在文本框開始位置插入「內容一」 text.insert(10, '內容二') #在文本框第10個索引位置插入「內容二」 text.insert(END, '內容三') #在文本框末尾插入「內容三」
刪除文本框裏直接位置值oop
#示例 text.delete(10) #刪除索引值爲10的值 text.delete(10, 20) #刪除索引值從10到20以前的值 text.insert(0, END) #刪除全部值
將光標移動到指定索引位置,只有當文框獲取焦點後成立學習
#示例 text.icursor(10) #移動光標到索引爲10的位置
獲取文件框的值字體
#示例 text.get() #返回文本框的值
返回指定的索引值操作系統
#示例 text.index(2)
選中指定索引和光標所在位置以前的值code
#示例 text.selection_adjust(2) #選中索引爲2和光標全部位置以前的全部值
清空文本框orm
#示例 text.selection_clear()
待定htm
選中指定索引以前的值,start必須比end小對象
#示例 text.selection_range(2, 10) #選中索引爲2和10以前的全部值
選中指定索引與光標之間的值(感受和selection_adjust差很少)
#示例 text.selection_to(2) #選中索引爲2和所光標所在位置以前的值
待定
待定
待定