How to create a D.O.B. collection form.


in this project we will learn how to design a form to collect Date of Birth information.

Below code will design the above form


#program

try:
from Tkinter import *
except:
from tkinter import *

mw = Tk()

mw.geometry(
"600x100+50+50")
mw.title(
"AETies : Automation Expert Technologies")

hdng = Label(mw
, text='A simple format of REGISTRATION FORM ', fg='blue', pady=10).pack()

# ********** designing date of birth section **********
dob_l = Label(mw, text='D.O.B(dd/mm/yyyy) :\t', ).place(x=10, y=50)
dd = Spinbox(mw
, from_=1, to=31, width=3).place(x=180, y=50)
mm = Spinbox(mw
, from_=1, to=12, width=3).place(x=240, y=50)
yy = Spinbox(mw
, from_=1965, to=2020, width=5).place(x=300, y=50)

mainloop()


Now let's add a functionality to collect the selected value in date of birth field. value can either be changed by clicking on arrow or directly we can edit.



#program

try:
from Tkinter import *
except:
from tkinter import *

def collect_data():
print('date :', dd.get())
print('month:', mm.get())
print('year :', yy.get())

mw = Tk()

mw.geometry(
"600x100+50+50")
mw.title(
"AETies : Automation Expert Technologies")

hdng = Label(mw
, text='A simple format of REGISTRATION FORM ', fg='blue', pady=10).pack()

# ********** designing date of birth section **********
dob_l = Label(mw, text='D.O.B(dd/mm/yyyy) :\t', ).place(x=10, y=50)
dd = Spinbox(mw
, from_=1, to=31, width=3)
dd.place(
x=180, y=50)
mm = Spinbox(mw
, from_=1, to=12, width=3)
mm.place(
x=240, y=50)
yy = Spinbox(mw
, from_=1965, to=2020, width=5)
yy.place(
x=300, y=50)

btn = Button(mw
, text=' collect ', fg='red', command=collect_data).place(x=400, y=50)

mainloop()

#Output

date : 5
month: 8
year : 1990





Comments

Post a Comment

My photo
Techno Xpresss
Bangalore, Karnataka, India