tkinter_Entry和text
#encoding=utf-8import tkinter as tk#创建窗口,设置标题,大小window = tk.Tk()window.title("我的窗口")window.geometry("400x200")#创建一个Entry输入框,输入框输入字符以星号展示,show=None,展示原文,show="1"#展示1entry = tk.Entry(window,show="*")entry.pack()#定义函数:获取Entry输入框的内容并且插入到text文本框中#插入到text文本框的当前光标位置def insert_point(): entry_content = entry.get() text.insert("insert",entry_content)#text.insert("1.1",entry_content)插入到text文本框1行1列位置#定义函数:获取Entry输入框的内容并且插入到text文本框中#插入到text文本框的末尾def insert_end(): entry_content = entry.get() text.insert("end",entry_content)#创建Button,执行insert_point函数button_1 = tk.Button(window,text="insert point",width=15,height=2,font=10,command = insert_point)button_1.pack()#创建Button,执行insert_end数button_2 = tk.Button(window,text="insert end",width=15,height=2,font=12,command=insert_end)button_2.pack()#创建Text输入框text = tk.Text(window,width=20,height=2)text.pack()#循环检测窗口window.mainloop()
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。