Working with Entry Fields and Grid Layouts : Entry « Tkinker « Python Tutorial






Working with Entry Fields and Grid Layouts
from Tkinter import *

root = None
namentry = None
addressentry = None
name = None
address = None

def close_window() :
    global name
    global address
    global nameentry, addressentry
    name = nameentry.get()
    address = addressentry.get()
    root.destroy()

def DoInputForm(root):
    global nameentry, addressentry

    Label(root, text="Enter name:").grid(row=0, sticky=W)
    Label(root, text="Enter address:").grid(row=1, sticky=W)

    nameentry = Entry(root)
    addressentry = Entry(root)

    nameentry.grid(row=0, column=1)
    addressentry.grid(row=1, column=1)

    Button(root, text="Ok", command=close_window).grid(row=2, column=0)
    Button(root, text="Cancel", command=close_window).grid(row=2, column=1)

root = Tk()
DoInputForm(root)
root.mainloop()

print "Name: "+name
print "Address:"+ address








18.11.Entry
18.11.1.Read data from EntryRead data from Entry
18.11.2.Create a story based on user inputCreate a story based on user input
18.11.3.Working with Entry Fields and Grid LayoutsWorking with Entry Fields and Grid Layouts
18.11.4.Text WidgetsText Widgets