14.2 方法
方法 | 描述 |
---|---|
activate(index) | 选中index代表的行 |
bbox | 获取选中条目的矩形包围框 |
curselection() | 获得当前选中的条目,返回值是一个列表。列表中的内容是选中的条目的索引值。 |
delete(first,last=none) | 删除条目,可以是1额或者多个,如listbox.delete(3,4),删除全部(0,END)。 First:要删除条目的起始索引 Last:要删除条目的结束索引。如果没有设定,只删除first指定的索引条目。 |
get(first,last=none) | 获得1个或者多个条目。具体参数参加delete(first,last=none) 该函数的返回值是一个字符串列表。 |
index(index) | 返回index指定的索引值。index可以是ACTIVE,也可以是ANCHOR,还可以是坐标值“@x,y”。 |
insert(index, *elements) | 追加项值,如listbox.insert(0,“addBox1”,“addBox2”)。 Index,为添加项值的位置。可以添加1个或者多个项值。 |
itemcget(index, option) | 获取列表框中,index指定项的配置属性。 |
itemconfig(index, **options) | 修改列表框中,index指定项的配置属性。 |
nearest(y) | 返回最靠近y坐标的索引值。 |
see(index) | 保证index指定的项值在列表框中可见。 |
selection_anchor(index) select_anchor(index) |
将tk.ANCHOR的值设为index。 |
selection_clear(first, last=None) select_clear(first, last=None) |
取消选中,比如listbox.select_clear(0,1)。参数first,last的解释,参照函数delete(first,last)。 |
selection_includes(index) select_includes(index) |
检查index指定的项目是否被选中。 |
selection_set(first, last=None) select_set(first, last=None) |
添加1个或者多个项目到被选中集合。 |
size() | 返回列表框的条目总数。 |
xview() | 控制水平滚动。 |
xview_moveto(fraction) | 控制水平滚动 |
xview_scroll(number, what) | 控制水平滚动number指定的位置。What参数指定移动的单位。可以是“units”,也可以是”pages” |
yview(*what) | 控制垂直滚动。 |
yview_moveto(fraction) | 控制垂直滚动 |
yview_scroll(number, what) | 垂直移动到number指定的位置 |