Python GUI ---Tkinter-05
2017-07-27 本文已影响26人
hu9134
本篇文章主要介绍了Entry的使用,怎么获取Entry的值等
具体可见源码
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/7/27 下午3:00
# @Author : hukezhu
# @Site :
# @File : 0727-04.py
# @Software: PyCharm
from Tkinter import *
import tkMessageBox
def button1Action():
tkMessageBox.showinfo('Message', '账号:'+ var.get() + '\n' + '密码:' + var1.get() + '\n' + '您点击了登录' )
app = Tk()
var = StringVar()
var1 = StringVar()
Label(app,text='账号').grid(row=0,sticky = W)
input = Entry(app,textvariable=var).grid(row=0,column=1,sticky = E)
Label(app,text='密码').grid(row=1,sticky=W)
input1 = Entry(app,textvariable=var1).grid(row=1,column=1,sticky=E)
button = Button(app,text='登录',command=button1Action).grid(row=2,column=1,sticky=E)
app.mainloop()
运行结果图