-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestando.py
More file actions
43 lines (35 loc) · 1.45 KB
/
testando.py
File metadata and controls
43 lines (35 loc) · 1.45 KB
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
35
36
37
38
39
40
41
42
43
from Tkinter import *
root = Tk()
def find_in_grid(frame, row, column):
for children in frame.children.values():
info = children.grid_info()
#note that rows and column numbers are stored as string
if info['row'] == str(row) and info['column'] == str(column):
return children
return None
#create an array of button
width = 10
for i in range(width):
for j in range(width):
b = Button(root, text=str(i*width+j))
b.grid(row=i, column=j)
#Create two entries to set row and column to find. Changing entries print the
#text of the button (and flash it on compatible platforms)
def update(var, value, op):
r = row.get()
c = col.get()
b = find_in_grid(root, r, c)
if b:
print "button ({0},{1}) : {2}".format(r, c, b["text"])
b.flash()
Label(root,text="row:").grid(row=width,column=0)
row = StringVar()
row.trace('w',update)
Entry(root,textvar=row, width=3).grid(row=width,column=1)
Label(root,text="col:").grid(row=width,column=2)
col = StringVar()
col.trace('w',update)
Entry(root,textvar=col, width=3).grid(row=width,column=3)
row.set('3')
col.set('2')
mainloop()