我希望无形的标签显示为绿色应该“@”符号,但它不这样做,只是什么也不做。我希望这个能继续到下一个函数,一些我能自己做的事情。如果“@”符号不在字符串中,标签就会出现,但如果@符号实际在字符串中,标签就不接受它
from tkinter import *
class Traveller:
def __init__(self, parent):
self.E_email = "sd"
self.go = Frame(parent, width=500, height=450, bg="snow", pady=30, padx=10)
self.go.grid(row=1, column=0)
self.go.grid_propagate(0) # to reserve space required for frame
email = Label(self.go, text="Email:", bg="snow")
email.grid(row=3, column=0, sticky=E)
self.E_email = Entry(self.go, width=40)
self.E_email.grid(row=3, column=1, sticky=W, pady=4)
menuButton = Button(self.go, text="Continue", command=self.dataCheck)
menuButton.grid(row=8, column=1, pady=8)
self.meme = Label(self.go, text = "", bg = "snow")
self.meme.grid(row=9, column=0, columnspan = 3)
def dataCheck(self):
self.E_email = str(self.E_email)
if "@" in self.E_email:
self.meme.configure(text="memem", bg = "olive drab")
# main routine
if __name__ == "__main__":
root = Tk()
root.title("Traveller Details")
play = Traveller(root)
root.geometry("500x450+0+0")
root.mainloop()
您必须使用
self.E_mail.get()
来获取entry小部件内部的文本相关问题 更多 >
编程相关推荐