from tkinter import * def getmessage(): print(‘作品:%s‘% e1.get()) print(‘作者:%s‘% e2.get()) root = Tk() l1 = Label(root,text=‘作品:‘).grid(row = 0,column= 0) l2 = Label(root,text=‘作者:‘).grid(row = 1,column= 0) e1=Entry(root) e1.grid(row = 0,column= 1) e2=Entry(root,show=‘*‘)#改成密码不显示 e2.grid(row = 1,column= 1) b1=Button(root,text=‘获取信息‘,command = getmessage) .grid(row = 2,column= 0,sticky=W,padx = 10,pady = 5) b2=Button(root,text=‘退出‘,command =root.quit) .grid(row = 2,column= 1,sticky=E,padx = 10,pady = 5) mainloop()
时间: 2024-10-31 21:01:02