📄 listbox.n
字号:
'\"'\" Copyright (c) 1990 The Regents of the University of California.'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) listbox.n 1.38 97/10/31 12:58:47'\" .so man.macros.TH listbox n 8.0 Tk "Tk Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMElistbox \- Create and manipulate listbox widgets.SH SYNOPSIS\fBlistbox\fR \fIpathName \fR?\fIoptions\fR?.SO\-background \-foreground \-relief \-takefocus\-borderwidth \-height \-selectbackground \-width\-cursor \-highlightbackground \-selectborderwidth \-xscrollcommand\-exportselection \-highlightcolor \-selectforeground \-yscrollcommand\-font \-highlightthickness \-setgrid.SE.SH "WIDGET-SPECIFIC OPTIONS".OP \-height height HeightSpecifies the desired height for the window, in lines.If zero or less, then the desired height for the window is made justlarge enough to hold all the elements in the listbox..OP \-selectmode selectMode SelectModeSpecifies one of several styles for manipulating the selection.The value of the option may be arbitrary, but the default bindingsexpect it to be either \fBsingle\fR, \fBbrowse\fR, \fBmultiple\fR,or \fBextended\fR; the default value is \fBbrowse\fR..OP \-width width WidthSpecifies the desired width for the window in characters.If the font doesn't have a uniform width then the width of thecharacter ``0'' is used in translating from character units toscreen units.If zero or less, then the desired width for the window is made justlarge enough to hold all the elements in the listbox..BE.SH DESCRIPTION.PPThe \fBlistbox\fR command creates a new window (given by the\fIpathName\fR argument) and makes it into a listbox widget.Additionaloptions, described above, may be specified on the command lineor in the option databaseto configure aspects of the listbox such as its colors, font,text, and relief. The \fBlistbox\fR command returns its\fIpathName\fR argument. At the time this command is invoked,there must not exist a window named \fIpathName\fR, but\fIpathName\fR's parent must exist..PPA listbox is a widget that displays a list of strings, one per line.When first created, a new listbox has no elements.Elements may be added or deleted using widget commands describedbelow. In addition, one or more elements may be selected as describedbelow.If a listbox is exporting its selection (see \fBexportSelection\fRoption), then it will observe the standard X11 protocolsfor handling the selection.Listbox selections are available as type \fBSTRING\fR;the value of the selection will be the text of the selected elements, withnewlines separating the elements..PPIt is not necessary for all the elements to bedisplayed in the listbox window at once; commands described belowmay be used to change the view in the window. Listboxes allowscrolling in both directions using the standard \fBxScrollCommand\fRand \fByScrollCommand\fR options.They also support scanning, as described below..SH "INDICES".PPMany of the widget commands for listboxes take one or more indicesas arguments.An index specifies a particular element of the listbox, in any ofthe following ways:.TP 12\fInumber\fRSpecifies the element as a numerical index, where 0 correspondsto the first element in the listbox..TP 12\fBactive\fRIndicates the element that has the location cursor. This elementwill be displayed with an underline when the listbox has thekeyboard focus, and it is specified with the \fBactivate\fRwidget command..TP 12\fBanchor\fRIndicates the anchor point for the selection, which is set with the\fBselection anchor\fR widget command..TP 12\fBend\fRIndicates the end of the listbox..VS 8.0For most commands this refers to the last element in the listbox,but for a few commands such as \fBindex\fR and \fBinsert\fRit refers to the element just after the last one..VE.TP 12\fB@\fIx\fB,\fIy\fRIndicates the element that covers the point in the listbox windowspecified by \fIx\fR and \fIy\fR (in pixel coordinates). If noelement covers that point, then the closest element to thatpoint is used..LPIn the widget command descriptions below, arguments named \fIindex\fR,\fIfirst\fR, and \fIlast\fR always contain text indices in one ofthe above forms..SH "WIDGET COMMAND".PPThe \fBlistbox\fR command creates a new Tcl command whosename is \fIpathName\fR. Thiscommand may be used to invoke variousoperations on the widget. It has the following general form:.CS\fIpathName option \fR?\fIarg arg ...\fR?.CE\fIOption\fR and the \fIarg\fRsdetermine the exact behavior of the command. The followingcommands are possible for listbox widgets:.TP\fIpathName \fBactivate\fR \fIindex\fRSets the active element to the one indicated by \fIindex\fR..VS 8.0If \fIindex\fR is outside the range of elements in the listboxthen the closest element is activated..VEThe active element is drawn with an underline when the widgethas the input focus, and its index may be retrieved with theindex \fBactive\fR..TP\fIpathName \fBbbox\fR \fIindex\fRReturns a list of four numbers describing the bounding box ofthe text in the element given by \fIindex\fR.The first two elements of the list give the x and y coordinatesof the upper-left corner of the screen area covered by the text(specified in pixels relative to the widget) and the last twoelements give the width and height of the area, in pixels.If no part of the element given by \fIindex\fR is visible on thescreen,.VS 8.0or if \fIindex\fR refers to a non-existent element,.VEthen the result is an empty string; if the element ispartially visible, the result gives the full area of the element,including any parts that are not visible..TP\fIpathName \fBcget\fR \fIoption\fRReturns the current value of the configuration option givenby \fIoption\fR.\fIOption\fR may have any of the values accepted by the \fBlistbox\fRcommand..TP\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?Query or modify the configuration options of the widget.If no \fIoption\fR is specified, returns a list describing all ofthe available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR forinformation on the format of this list). If \fIoption\fR is specifiedwith no \fIvalue\fR, then the command returns a list describing theone named option (this list will be identical to the correspondingsublist of the value returned if no \fIoption\fR is specified). Ifone or more \fIoption\-value\fR pairs are specified, then the commandmodifies the given widget option(s) to have the given value(s); inthis case the command returns an empty string.\fIOption\fR may have any of the values accepted by the \fBlistbox\fRcommand..TP\fIpathName \fBcurselection\fRReturns a list containing the numerical indices ofall of the elements in the listbox that are currently selected.If there are no elements selected in the listbox then an emptystring is returned..TP\fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?Deletes one or more elements of the listbox. \fIFirst\fR and \fIlast\fRare indices specifying the first and last elements in the rangeto delete. If \fIlast\fR isn't specified it defaults to\fIfirst\fR, i.e. a single element is deleted..TP\fIpathName \fBget \fIfirst\fR ?\fIlast\fR?If \fIlast\fR is omitted, returns the contents of the listboxelement indicated by \fIfirst\fR,.VS 8.0or an empty string if \fIfirst\fR refers to a non-existent element..VEIf \fIlast\fR is specified, the command returns a list whose elementsare all of the listbox elements between \fIfirst\fR and \fIlast\fR,inclusive.Both \fIfirst\fR and \fIlast\fR may have any of the standardforms for indices..TP\fIpathName \fBindex \fIindex\fRReturns the integer index value that corresponds to \fIindex\fR..VS 8.0If \fIindex\fR is \fBend\fR the return value is a count of the numberof elements in the listbox (not the index of the last element)..VE.TP\fIpathName \fBinsert \fIindex \fR?\fIelement element ...\fR?Inserts zero or more new elements in the list just before theelement given by \fIindex\fR. If \fIindex\fR is specified as\fBend\fR then the new elements are added to the end of thelist. Returns an empty string..TP\fIpathName \fBnearest \fIy\fRGiven a y-coordinate within the listbox window, this command returnsthe index of the (visible) listbox element nearest to that y-coordinate..TP\fIpathName \fBscan\fR \fIoption args\fRThis command is used to implement scanning on listboxes. It hastwo forms, depending on \fIoption\fR:.RS.TP\fIpathName \fBscan mark \fIx y\fRRecords \fIx\fR and \fIy\fR and the current view in the listboxwindow; used in conjunction with later \fBscan dragto\fR commands.Typically this command is associated with a mouse button press inthe widget. It returns an empty string..TP\fIpathName \fBscan dragto \fIx y\fR.This command computes the difference between its \fIx\fR and \fIy\fRarguments and the \fIx\fR and \fIy\fR arguments to the last\fBscan mark\fR command for the widget.It then adjusts the view by 10 times thedifference in coordinates. This command is typically associatedwith mouse motion events in the widget, to produce the effect ofdragging the list at high speed through the window. The returnvalue is an empty string..RE.TP\fIpathName \fBsee \fIindex\fRAdjust the view in the listbox so that the element given by \fIindex\fRis visible.If the element is already visible then the command has no effect;if the element is near one edge of the window then the listboxscrolls to bring the element into view at the edge; otherwisethe listbox scrolls to center the element..TP\fIpathName \fBselection \fIoption arg\fRThis command is used to adjust the selection within a listbox. It
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -