-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.py
More file actions
22 lines (19 loc) · 862 Bytes
/
Table.py
File metadata and controls
22 lines (19 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Table(tk.Frame):
def __init__(self, parent, rows=10, columns=2):
# use black background so it "peeks through" to
# form grid lines
tk.Frame.__init__(self, parent, background="black")
self._widgets = []
for row in range(rows):
current_row = []
for column in range(columns):
label = tk.Label(self, text="%s/%s" % (row, column),
borderwidth=0, width=10)
label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
current_row.append(label)
self._widgets.append(current_row)
for column in range(columns):
self.grid_columnconfigure(column, weight=1)
def set(self, row, column, value):
widget = self._widgets[row][column]
widget.configure(text=value)