python学习日记第七天tkinter模块4
import tkinter as tk#创建窗口window=tk.Tk()#窗口命名window.title("My window")#设置窗口大小window.geometry(‘500x300‘)#设置Entry并放置e=tk.Entry(window,show=None)e.pack()#定义两个触发事件的函数insert_point和insert_end(注意:因为python的执行顺序是从上到下的,所以函数一定要放到按钮上面)def insert_point(): #在鼠标交点处输入插入内容 var=e.get() t.insert(‘insert‘,var)def insert_end(): var=e.get() t.insert(‘end‘,var)#创建并放置两个按钮分别触发两种情况b1=tk.Button(window,text=‘insert point‘,width=10,height=2,command=insert_point)b1.pack()b2=tk.Button(window,text=‘insert end‘,width=10,height=2,command=insert_end)b2.pack()#创建并放置一个多行文本框text用以显示t=tk.Text(window,height=3)t.pack()#主窗口无限循环window.mainloop()
相关推荐
lsjweiyi 2020-11-17
YENCSDN 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16