1
"""Sample taken from: http://www.tkdocs.com/tutorial/morewidgets.html and
2
converted to Python, mainly to demonstrate xscrollcommand option.
4
grid [tk::listbox .l -yscrollcommand ".s set" -height 5] -column 0 -row 0 -sticky nwes
5
grid [ttk::scrollbar .s -command ".l yview" -orient vertical] -column 1 -row 0 -sticky ns
6
grid [ttk::label .stat -text "Status message here" -anchor w] -column 0 -row 1 -sticky we
7
grid [ttk::sizegrip .sz] -column 1 -row 1 -sticky se
8
grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1
9
for {set i 0} {$i<100} {incr i} {
10
.l insert end "Line $i of 100"
14
from tkinter import ttk
18
l = tkinter.Listbox(height=5)
19
l.grid(column=0, row=0, sticky='nwes')
21
s = ttk.Scrollbar(command=l.yview, orient='vertical')
22
l['yscrollcommand'] = s.set
23
s.grid(column=1, row=0, sticky="ns")
25
stat = ttk.Label(text="Status message here", anchor='w')
26
stat.grid(column=0, row=1, sticky='we')
29
sz.grid(column=1, row=1, sticky='se')
31
root.grid_columnconfigure(0, weight=1)
32
root.grid_rowconfigure(0, weight=1)
35
l.insert('end', "Line %d of 100" % i)