Entry Fields in a row : TextField Entry : GUI Tk PYTHON examples


PYTHON examples » GUI Tk » TextField Entry »

 

Entry Fields in a row


Entry Fields in a row
 
from Tkinter import *

fields = 'First Name', 'Last Name', 'Job'

def fetch(entries):
    for entry in entries:
        print 'Input => "%s"' % entry.get()

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

def show(entries):
    fetch(entries)
    popup.destroy()

def ask():
    global popup
    popup = Toplevel()
    ents = makeform(popup, fields)
    Button(popup, text='OK', command=(lambda e=ents: show(e)) ).pack()
    popup.grab_set()
    popup.focus_set()
    popup.wait_window()

root = Tk()
Button(root, text='Dialog', command=ask).pack()
root.mainloop()



           
         
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo GUI Tk
» TextField Entry