输入框和消息显示框是常用的GUI界面部件,其中输入框的重要任务就是返回一个输入的字符串,而消息显示框则要显示指定的信息。
功能:输入一个密码,如果密码正确则显示confirm,不正确则显示sorry
__author__ = 'freedom'
from Tkinter import *
class App(Frame):
def __init__(self,master):
frame = Frame(master)
frame.grid()
self.ent = Entry(frame,show = "*")
self.ent.grid(row = 0,column = 0,sticky = W)
self.button = Button(frame)
self.button["text"] = "submit"
self.button["command"] = self.subm
self.button.grid(row = 0,column = 1,sticky = W)
self.txt = Text(frame,width = 35,height = 5,wrap = WORD)
self.txt.grid(row = 3,column = 0,columnspan = 2,sticky = W)
def subm(self):
context = self.ent.get()
if context == "hello