4. Building a Simple User Information Form with Python Tkinter | GUI Application Tutorial

KidzCode
KidzCode
143 بار بازدید - 8 ماه پیش - Learn how to create a
Learn how to create a user-friendly GUI application in Python using Tkinter! In this tutorial, we'll build a simple User Information Form that collects a user's first name, last name, and email address. The script includes a responsive interface and a 'Save and Display' button that showcases the entered information. Follow along with the code, and enhance your Python GUI skills! #Python #Tkinter #GUIApplication #ProgrammingTutorial.

code goes here-
import tkinter as tk


root = tk.Tk()
all the widgets
title = tk.Label(root,text="Name and E-mail Reader\n")
first_name_label = tk.Label(root,text="Type your first name:")
first_name_entry = tk.Entry(root)
last_name_label = tk.Label(root,text="Type your last name:")
last_name_entry = tk.Entry(root)
email_label = tk.Label(root,text="Type your email:")
email_entry = tk.Entry(root)
save_button = tk.Button(root,text="Save & Display")
display_label = tk.Label(root,text="")


packing
title.pack()
first_name_label.pack()
first_name_entry.pack()
last_name_label.pack()
last_name_entry.pack()
email_label.pack()
email_entry.pack()
save_button.pack()
display_label.pack()

#function to read and save all the details from the entries
def read_data():
 first_name = first_name_entry.get()
 last_name = last_name_entry.get()
 email = email_entry.get()
 pass the details to the display label
 display_label.config(text="Hello, "+first_name+" "+last_name+"!"+"\nEmail: "+email)

pass the function to the button
save_button.config(command=read_data)




root.mainloop()
8 ماه پیش در تاریخ 1402/10/03 منتشر شده است.
143 بـار بازدید شده
... بیشتر