Tkintertextmsgbox

.py
School
University Of Arizona**We aren't endorsed by this school
Course
CSC PYTHON
Subject
Computer Science
Date
Dec 16, 2024
Pages
1
Uploaded by BasharShalabi
from tkinter import messageboxfrom tkinter import *def createWidgets():# create the label widgets for the two textboxes and place them on the gridLabel(root, text="First Name").grid(row=0, padx=10, pady=10)Label(root, text="Last Name").grid(row=1, padx=10, pady=10)# create the two textboxesfirst_name_txt = Entry(root)last_name_txt = Entry(root)# place the two textboxes on the gridfirst_name_txt.grid(row=0, column=1, padx=10, pady=10)last_name_txt.grid(row=1, column=1, padx=10, pady=10)# create the OK button and place it on the gridbtnOK = Button(root, text="OK", command=btnOKClick)btnOK.grid(row=2, column=2, padx=10, pady=10)# create the Cancel button and place it on the gridbtnCancel = Button(root, text="Cancel", command=btnCancelClick)btnCancel.grid(row=2, column=3, padx=10, pady=10)# Event Handler for the OK Buttondef btnOKClick():messagebox.showinfo(title='Event Handler for OK Button', message="The user selected the OK Button", detail='')# Event Handler for the Cancel Buttondef btnCancelClick():messagebox.showinfo(title='Event Handler for Cancel Button', message="The user selected the Cancel Button", detail='')# create the root applicationroot = Tk()# create the widgets on the root application windowcreateWidgets()# run the applicationmainloop()
Background image