Question: Hello, this is a Tkinter GUI in Python. I want to be able to check if the user has entered appropriate characters in entry box.
Hello, this is a Tkinter GUI in Python. I want to be able to check if the user has entered appropriate characters in entry box. For example, if user enters a number in one of the boxes, or left one of the entry boxes empty, a message pops-up saying to try again and fill in form appropriately. Thanks.
This is my code so far:
from tkinter import * import tkinter.messagebox
class MyGUI:
def __init__(self): self = Tk() self.geometry("500x500") Label(self, text= "Please fill-out this form:", fg="black", font=("Arial", 18, "bold")).place(x=100, y=180) Label(self, text= "First Name:", fg="black", font=("Arial", 16)).place(x=100, y=220) Entry(self, width= 10, font=("Arial", 14)).place(x=220, y=220) Label(self, text= "Last Name:", fg="black", font=("Arial", 16)).place(x=100, y=260) Entry(self, width= 10, font=("Arial", 14)).place(x=220, y=260) Label(self, text= "Email:", fg="black", font=("Arial", 16)).place(x=100, y=300) Entry(self, width= 20, font=("Arial", 14)).place(x=220, y=300) button1 = Button(self, text="OK", font=("Arial", 16), command=form_message) button1.place(x=220,y=340) def form_message(): tkinter.messagebox.showinfo("Response", "An email was sent to you!") my_gui =MyGUI()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
