-
-background =>
color
Sets the color of the area behind the
text.
-borderwidth =>
amount
Sets the width of the edges of the widget.
Default is 2.
-cursor =>
cursorname
- Sets the cursor to display when the mouse is over the Listbox. -exportselection => 0 | 1
- Determines if the current Listbox selection is made available for the X selection as well. If set to 1, prevents two Listboxes from having selections at the same time. -font => fontname
- Sets the font of any text displayed within the Listbox. -foreground => color
- Sets the color of nonselected text displayed in the Listbox. -height => amount
- Sets the height of the Listbox. -highlightbackground => color
- Sets the color the highlight rectangle should be when the Listbox does not have the keyboard focus. -highlightcolor => color
- Sets the color the highlight rectangle should be when the Listbox does have the keyboard focus. -highlightthickness => amount
- Sets the thickness of the highlight rectangle. Default is 2. -relief => 'flat'|'groove'|'raised'|'ridge'|' sunken '|'solid'
- Sets the relief of the edges of the Listbox. -selectbackground => color
- Sets the color behind any selected text. -selectborderwidth => amount
- Sets the width of the border around any selected text. -selectforeground => color
- Sets the color of the text in any selected items. -selectmode => "single" | " browse " | "multiple" | "extended"
- Affects how many items can be selected at once; also affects some key/mouse bindings for the Listbox (such as Shift-select). -setgrid => 0 | 1
- Turns gridding off or on for the Listbox. Default is 0. -takefocus => 0 | 1 | undef
- Determines whether the widget can have keyboard focus. 0 means never, 1 means always, undef means dynamic decision. -width => amount
- Sets the width of the Listbox in characters. If amount is 0 or less, the Listbox is made as wide as the longest item. -xscrollcommand => callback
- Assigns a horizontal Scrollbar to widget. -yscrollcommand => callback
- Assigns a vertical Scrollbar to widget.
- Selection Mode:
- browse and single
- These modes are similar in that only one item can be selected at a time; clicking on any item will deselect any other selection in the Listbox. The browse mode has a slight difference: when the mouse is held down and moving around, the selection moves with the mouse. For bind purposes, a "<Button-1>" bind will be invoked when you first click down. If you want to catch the event when the mouse is released, define a ButtonRelease binding. extended
- This mode lets you select more than one item at a time. Clicking on a single item with the left mouse button will deselect any other selection, but you can Shift-click or Control-click to add more items to your selection. Shift-clicking (holding down the Shift key while pressing a mouse button) will extend the selection from the already selected item to the newly selected item. Control-clicking (holding down the Control key while pressing a mouse button) will add the item being clicked to the selection, but it won't alter any of the other selections. You can also click an item with the mouse button, hold down the button, and then move the pointer over other items to select them. This is what's called a click-drag motion. Using "extended" allows for very fast selection of many different items in the Listbox. multiple
- This mode also allows you to select more than one item. Instead of Shift-clicking or Control-clicking, you select items one at a time. Clicking on an unselected item will select it, and clicking on an already selected item will unselect it.
- Insert Item:
-
$lb->insert(index , element , element ... );
index 0 和end 分别代表最前面和最后面
删除item:
$lb->delete(firstindex [, lastindex ] );
$lb->delete(0, 'end');删除所有的item
获取item:
The get method returns a list of Listbox elements specified by the indexes firstindex to lastindex :
$lb->get(firstindex [, lastindex ] );
@elements = $lb->get(0, 'end');
To get the last item in the Listbox:
$lastitem = $lb->get('end');
To find out which items in the Listbox are selected, use the curselection method:
@list = $lb->curselection();
$lb->delete(firstindex [, lastindex ] );
获取item大小:
$count = $lb->size( );