温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

tkinter_Entry和text

发布时间:2020-06-27 13:10:06 来源:网络 阅读:579 作者:qq5a16e6241946e 栏目:编程语言
#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()
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI