Here is how you call the constructor for a ScrolledList widget.
s=ScrolledList(master, width=W, height=H, vscroll=VS, hscroll=HS, callback=c)
where:
s
The constructor returns a new ScrolledList widget that
has not been registered. Be
sure to register it with the .grid()
method or it will not appear in your application.
master
The parent Frame widget in which the
new ScrolledList widget is to be mastered.
width=W
The width of the Listbox in
characters. The default value is 40.
height=H
The height of the Listbox in lines.
The default value is 25.
vscroll=VS
By default, you will get a vertical scrollbar. If
you don't want one, use “vscroll=0”.
hscroll=HS
By default, you will not get a
horizontal scrollbar. If you do want one, use “hscroll=1”.
callback=c
If you want your application to react whenever a user
clicks on a line in the Listbox,
use this keyword argument to supply a function c, and that function will be called whenever
the user clicks on a line. You should define your
function like this:
def c ( lineNo ):
...
where the lineNo argument will be the
index (starting at 0) of the line on which the user
clicked. For example, if the user clicks on the
third line, the ScrolledList widget will call your procedure
with an argument 2.
These attributes of a ScrolledList widget are visible.
.width
The width of the listbox in characters when the widget was constructed.
.height
The height of the listbox in lines when the widget was constructed.
.listbox
The Tkinter Listbox widget inside
the ScrolledList widget. If you want to change the
appearance of the listbox, use this attribute's
.configure() method.
For example, if you have a font object (tkFont.Font) named ttFont,
and you would like to apply it to a ScrolledList widget
named optionBox, this would do it:
optionBox.listbox.configure(font=ttFont)
These methods are defined on a ScrolledList widget.
.count()
Returns the number of lines currently contained in the listbox.
.__getitem__(self, i)
To retrieve the text of the ith line in the
listbox, you can use the regular Python index
operator. For example, if you have a ScrolledList object
named optionBox, the expression
“optionBox[2]” would
return the contents of the third line.
.append(s)
Adds a string as the next line in the listbox.
s
.insert(linex,
s)
Inserts a string as a new line before
position s. For example, to add a new first line
containing “linexMerlin” to
a ScrolledList widget named s:
s.insert(0, 'Merlin')
.delete(linex)
Deletes a line from the listbox; is the
index of the line, starting from 0.
linex
.clear()
Removes all lines from the listbox.