Breaking

Wednesday, 11 April 2018

Simple Form design in python with Tkinter

Simple Form design in python with Tkinter without and validations and database.



from tkinter import *
fields = 'First Name', 'Last Name', 'DOB', 'Email','Contact'


def fetch(entries):
   for entry in entries:
      field = entry[0]
      text  = entry[1].get()
      print('%s: "%s"' % (field, text))
    


def makeform(root, fields):
   entries = []
   for field in fields:
      row = Frame(root)
      lab = Label(row, width=15, text=field, anchor='w')
      ent = Entry(row)
      row.pack(side=TOP, fill=X, padx=5, pady=5)
      lab.pack(side=LEFT)
      ent.pack(side=RIGHT, expand=YES, fill=X)
      entries.append((field, ent))
   return entries
 #ssachin Ujjainkar


if __name__ == '__main__':
   root = Tk()
   w = Label(root, text="Exam Form ", bg="gray", fg="white")
   w.pack(fill=X)
   ents = makeform(root, fields)
     
   root.bind('<Return>', (lambda event, e=ents: fetch(e)))
   
   b1 = Button(root, text='Submit',command=(lambda e=ents: fetch(e)))
   b1.pack(side=BOTTOM, padx=5, pady=10)
   b2 = Button(root, text='Quit', command=root.quit)
   b2.pack(side=BOTTOM, padx=5, pady=10)

   root.mainloop()


Developed by :  #ssachin Ujjainkar



OUTPUT






No comments:

Post a Comment