test5.py
1.08 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
44
45
46
from tkinter import *
from tkscrolledframe import ScrolledFrame
#from scrollframe import ScrollFrame
# Create a root window
root = Tk()
# Create a ScrolledFrame widget
#sf = ScrollFrame(root)
sf=ScrolledFrame(root)
sf.pack(side="top", expand=1, fill="both")
# Bind the arrow keys and scroll wheel
sf.bind_arrow_keys(root)
sf.bind_scroll_wheel(root)
# Create a frame within the ScrolledFrame
inner_frame = sf.display_widget(Frame)
# Add a bunch of widgets to fill some space
num_rows = 160
num_cols = 1
for row in range(num_rows):
for column in range(num_cols):
w=None
#w = Button(sf.viewPort,
w = Button(inner_frame,
width=15,
height=15,
borderwidth=2,
#relief="groove",
#anchor="center",
#justify="center",
text=str(row * num_cols + column))
w.config(command=w.destroy)
w.pack()
#w.grid(row=row,
# column=column,
# padx=4,
# pady=4)
# Start Tk's event loop
root.mainloop()