首页 > 其他 > 详细

tkinter_Entry和text

时间:2018-10-31 13:45:47      阅读:173      评论:0      收藏:0      [点我收藏+]
#encoding=utf-8 import tkinter as tk #创建窗口,设置标题,大小 window = tk.Tk() window.title("我的窗口") window.geometry("400x200") #创建一个Entry输入框,输入框输入字符以星号展示,show=None,展示原文,show="1" #展示1 entry = 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()

tkinter_Entry和text

原文:http://blog.51cto.com/13496943/2311070

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!