-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry3.py
34 lines (31 loc) · 960 Bytes
/
entry3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from tkinter import *
from quitter import Quitter
fields = 'Name', 'Job', 'Pay'
def fetch(variables):
for variable in variables:
print('Input => "%s' % variable.get())
def makeform(root, fields):
variables = []
form = Frame(root)
left = Frame(form)
rite = Frame(form)
form.pack(fill=X)
left.pack(side=LEFT)
rite.pack(side=RIGHT, expand=YES, fill=X)
for field in fields:
lab = Label(left, width=5, text=field)
ent = Entry(rite)
lab.pack(side=TOP)
ent.pack(side=TOP, fill=X)
var = StringVar()
ent.config(textvariable=var)
var.set('enter here')
variables.append(var)
return variables
if __name__ == '__main__':
root = Tk()
vars = makeform(root, fields)
root.bind('<Return>',(lambda event: fetch(vars)))
Button(root, text='Fetch', command=(lambda : fetch(vars))).pack(side=LEFT)
Quitter(root).pack(side=RIGHT)
root.mainloop()