CHECKBUTTON and ENTRY widget in TKINTER
from tkinter import *
root = Tk()
def getvalue():
print("Submitting your form")
print(f"{nvalue.get(), fvalue.get(), ovalue.get(), avalue.get()} ")
with open("records.txt", "a") as f:
f.write(f"\n{nvalue.get(), fvalue.get(), ovalue.get(), avalue.get()} ")
root.geometry("600x300")
Label(text="Welcome to Abdur GUI", font="verdana 16 bold").grid(column=1)
name = Label(root, text="Name:")
fname = Label(root, text="Father Name:")
ocupation = Label(root, text="Occupation:")
age = Label(root, text="Age:")
name.grid(row=1)
fname.grid(row=2)
ocupation.grid(row=3)
age.grid(row=4)
nvalue = StringVar()
fvalue = StringVar()
ovalue = StringVar()
avalue = StringVar()
bookingval = IntVar()
n_entry = Entry(root, textvariable=nvalue)
f_entry = Entry(root, textvariable=fvalue)
o_entry = Entry(root, textvariable=ovalue)
a_entry = Entry(root, textvariable=avalue)
booking_checkbox = Checkbutton(text="Want to book a hotel", variable = bookingval).grid(row=5,column=1)
n_entry.grid(row=1,column=1)
f_entry.grid(row=2,column=1)
o_entry.grid(row=3,column=1)
a_entry.grid(row=4,column=1)
Button(text="submit", command=getvalue).grid(row=6)
root.mainloop()
Comments
Post a Comment
Write something to CodeWithAbdur!