【发布时间】:2015-02-03 10:25:28
【问题描述】:
我创建了一个程序,该程序基本上可以验证汽车注册号,执行速度计算,然后如果用户的注册号无效或违反了速度限制,则将用户详细信息写入记事本,它工作正常。现在我尝试使用 tkinter 使其更具交互性,但由于某种原因它没有连接到 while 循环。
tkinter 程序:
import tkinter
from tkinter import *
import random
from random import randint
import re
def show_entry_fields():
print("First Name: %s\nLast Name: %s\nRegistration number:%s" % (Fname.get(), Lname.get(), reg.get()))
momma = Tk()
Label(momma, text="First Name").grid(row=0)
Label(momma, text="Last Name").grid(row=1)
Label(momma, text="please enter your registration number:").grid(row=2)
Fname = Entry(momma)
Lname = Entry(momma)
reg = Entry(momma)
Fname.grid(row=0, column=1)#colim = Insert the widget at this column.
Lname.grid(row=1, column=1)
reg.grid(row=2, column=1)
Button(momma, text='Quit', command=momma.quit).grid(row=3, column=0, sticky=W, pady=4)
Button(momma, text='Show', command=show_entry_fields).grid(row=3, column=1, sticky=W, pady=4)
mainloop()
while reg== re.match('^[A-Z]{2}[0-9]{2}[A-Z]{3}$', reg):
w= Message(momma, text="that is a valid registration number")
w.pack()
break
真的很想帮助将程序的开始连接到while循环。提前致谢。
【问题讨论】:
标签: python loops while-loop tkinter