📄 tabnotebook.n
字号:
a seamless part of its notebook page. Tabs can be controlled in their location along the edges, the angle tab sides are drawn with, gap between tabs, starting margin of tabs, internal padding around text labels in a tab, the font, and its label. .PPThe Tab area is implemented with the \fBtabset\fR mega widget. See \fBtabset(1)\fR. Tabs may be oriented along either the north, south, east, or west sides with the \fBtabPos\fR option. North and south tabs may appear as angled, square, or bevelled. West and east tabs may appear as square or bevelled. By changing tab gaps, tab angles, bevelling, orientations, colors, fonts, start locations, and margins; tabs may appear in a wide variety of styles. For example, it is possible to implement Microsoft-style tabs, Borland property tab styles, or Borland Delphi style tabs all with the same tabnotebook..SH "WIDGET-SPECIFIC METHODS".PPThe \fBtabnotebook\fR command creates a new Tcl command whose name is \fIpathName\fR. This command may be used to invoke various operations on the widget. It has the following general form:.DS C\fIpathName option \fR?\fIarg arg ...\fR?.DE\fIoption\fR and the \fIarg\fRsdetermine the exact behavior of the command..PPMany of the widget commands for a notebook take as one argument an indicator of which page of the notebook to operate on. These indicators are called indexes and may be specified in any of the following forms:.TP\fInumber\fRSpecifies the page numerically, where 0 corresponds to the first page in the notebook, 1 to the second, and so on..TP\fBselect\fRSpecifies the currently selected page's index. If no page is currently selected, the value -1 is returned..TP\fBend\fRSpecifes the last page in the tabnotebook's index. If the notebook is empty this will return -1..TP\fIpattern\fRIf the index doesn't satisfy any of the above forms, then this form is used. Pattern is pattern-matched against the label of each page in the notebook, in order from the first to the last page, until a matching entry is found. The rules of Tcl_StringMatch are used.'.............................................................................The following commands are possible for tabnotebook widgets:.TP\fIpathName\fR \fBadd\fR ?\fIoption\fR \fIvalue\fR \fIoption\fR \fIvalue\fR ...?Add a new page at the end of the tabnotebook. A new child site frame is created. Returns the child site pathName. If additional arguments are present, they specify any of the following options:.RS.TP\fB-angle\fR \fIvalue\fRSpecifes the angle of slope from the inner edge to the outer edge of the tab. An angle of 0 specifies square tabs. Valid ranges are 0 to 45 degrees inclusive. Default is 15 degrees. If this option is specified as an empty string (the default), then the angle option for the overall tabnotebook is used. This is generally only set at the tabnotebook level. Tabs normally will want to share the same angle value..TP\fB-background\fR \fIvalue\fRSpecifies a background color to use for displaying tabs when they are selected and for displaying the current page. If this option is specified as an empty string (the default), then the background option for the overall tabnotebook is used..TP\fB-bevelamount\fR \fIvalue\fRSpecifes the size of tab corners. A value of 0 with angle set to 0 results in square tabs. A bevelAmount of 4, means that the tab will be drawn with angled corners that cut in 4 pixels from the edge of the tab. The default is 0. This is generally only set at the tabnotebook level. Tabs normally will want to share the same bevelAmount..TP\fB-bitmap\fR \fIvalue\fRIf label is a non-empty string, specifies a bitmap to display in this page's tab. Bitmap may be of any of the forms accepted by Tk_GetPixmap. .TP\fB-command\fR \fIvalue\fRSpecifies a Tcl command to be executed when this page is selected. This allows the programmer a hook to reconfigure this page's widgets or any other page's widgets..IPIf the tabnotebook has the auto option set to true, when a page is selected this command will be called immediately after the previously selected page is unpacked and immediately before this page is selected. The index value select is valid during this Tcl command. `index select' will return this page's page number. .IPIf the auto option is set to false, when a page is selected the unpack and pack calls are bypassed. This Tcl command is still called..TP\fB-disabledforeground\fR \fIvalue\fRSpecifies a foreground color to use for displaying tab labels when tabs are in their disable state. If this option is specified as an empty string (the default), then the disabledforeground option for the overall tabnotebook is used..TP\fB-font\fR \fIvalue\fRSpecifies the font to use when drawing a text label on a page tab. If this option is specified as an empty string then the font option for the overall tabnotebook is used...TP\fB-foreground\fR \fIvalue\fRSpecifies a foreground color to use for displaying tab labels when they are selected. If this option is specified as an empty string (the default), then the foreground option for the overall tabnotebook is used..TP\fB-label\fR \fIvalue\fRSpecifies a string to display as an identifying label for a notebook page. This label serves as an additional identifier used to reference the page. This label may be used for the index value in widget commands..TP\fB-tabbackground\fR \fIvalue\fRSpecifies a background color to use for displaying a tab when it is not elected. If this option is specified as an empty string (the default), then the tabBackground option for the overall tabnotebook is used..TP\fB-tabforeground\fR \fIvalue\fRSpecifies a foreground color to use for displaying the tab's text label when it is not selected. If this option is specified as an empty string (the default), then the tabForeground option for the overall tabnotebook is used..TP\fB-padx\fR \fIvalue\fRSpecifies a non-negative value indicating how much extra space to request for a tab around its label in the X-direction. When computing how large a window it needs, the tab will add this amount to the width it would normally need The tab will end up with extra internal space to the left and right of its text label. This value may have any of the forms acceptable to Tk_GetPixels. If this option is specified as an empty string (the default), then the padX option for the overall tabnotebook is used.TP\fB-pady\fR \fIvalue\fRSpecifies a non-negative value indicating how much extra space to request for a tab around its label in the Y-direction. When computing how large a window it needs, the tab will add this amount to the height it would normally need The tab will end up with extra internal space to the top and bottom of its text label. This value may have any of the forms acceptable to Tk_GetPixels. If this option is specified as an empty string (the default), then the padY option for the overall tabnotebook is used.TP\fB-state\fR \fIvalue\fRSpecifies one of two states for the page: normal or disabled. In normal state unselected tabs are displayed using the tabforeground and tabbackground option from the tabnotebook or the page. Selected tabs and pages are displayed using the foreground and background option from the tabnotebook or the page. The disabled state means that the page and its tab is insensitive: it doesn't respond to mouse button presses or releases. In this state the entry is displayed according to its disabledForeground option for the tabnotebook and the background/tabbackground option from the page or the tabnotebook..RE.TP'>>>>>>>>>>\fIpathName\fR \fBchildSite\fR ?\fIindex\fR?If passed no arguments, returns a list of pathNames for all the pages in the tabnotebook. If the tab notebook is empty, an empty list is returned.IPIf \fIindex\fR is passed, it returns the \fIpathName\fR for the page's child site \fBframe\fR specified by \fIindex\fR. Widgets that are created with this \fIpathName\fR will be displayed when the associated page is selected. If \fIindex\fR is not a valid index, an empty string is returned. .TP\fIpathName\fR \fBconfigure\fR ?\fIoption\fR? ?\fIvalue\fR \fIoption\fR \fIvalue\fR ...?Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. \fIOption\fR may have any of the values accepted by the tabnotebook command..TP\fIpathName\fR \fBdelete\fR \fIindex1\fR ?\fIindex2\fR?Delete all of the pages between \fIindex1\fR and \fIindex2\fR inclusive. If \fIindex2\fR is omitted then it defaults to \fIindex1\fR. Returns an empty string..TP\fIpathName\fR \fBindex\fR \fIindex\fRReturns the numerical index corresponding to \fIindex\fR..TP\fIpathName\fR \fBinsert\fR \fIindex\fR ?\fIoption\fR \fIvalue\fR \fIoption\fR \fIvalue\fR ...?Insert a new page in the tabnotebook before the page specified by \fIindex\fR. A new child site \fBframe\fR is created. The additional arguments are the same as for the \fBadd\fR command. Returns the child site \fIpathName\fR..TP\fIpathName\fR \fBnext\fRAdvances the selected page to the next page (order is determined by insertion order). If the currently selected page is the last page in the notebook, the selection wraps around to the first page in the notebook. It behaves as if the user selected the new page..IPFor notebooks with \fBauto\fR set to \fBtrue\fR the current page's child site is unpacked from the notebook's child site frame. Then the next page's child site is packed into the notebook's child site frame. The Tcl command given with the command option will be invoked between these two operations..IPFor notebooks with \fBauto\fR set to \fBfalse\fR the Tcl command given with the command option will be invoked..TP\fIpathName\fR \fBpageconfigure\fR \fIindex\fR ?\fIoption\fR? ?\fIvalue\fR \fIoption\fR \fIvalue\fR ...?This command is similar to the \fBconfigure\fR command, except that it applies to the options for an individual page, whereas configure applies to the options for the tabnotebook as a whole. \fIOptions\fR may have any of the values accepted by the add widget command. If options are specified, options are modified as indicated in the command and the command returns an empty string. If no options are specified, returns a list describing the current options for page index (see \fBTk_ConfigureInfo\fRfor information on the format of this list)..TP\fIpathName\fR \fBprev\fRMoves the selected page to the previous page (order is determined by insertion order). If the currently selected page is the first page in the notebook, the selection wraps around to the last page in the notebook. It behaves as if the user selected the new page..IPFor notebooks with \fBauto\fR set to \fBtrue\fR the current page's child site is unpacked from the notebook's child site \fBframe\fR. Then the previous page's child site is packed into the notebook's child site frame. The Tcl command given with the command option will be invoked between these two operations..IPFor notebooks with \fBauto\fR set to \fBfalse\fR the Tcl command given with the command option will be invoked..TP\fIpathName\fR \fBselect\fR \fIindex\fRSelects the page specified by \fIindex\fR as the currently selected page. It behaves as if the user selected the new page..IPFor notebooks with \fBauto\fR set to \fBtrue\fR the current page's child site is unpacked from the notebook's child site frame. Then the \fIindex\fR page's child site is packed into the notebook's child site frame. The Tcl command given with the command option will be invoked between these two operations..IPFor notebooks with \fBauto\fR set to \fBfalse\fR the Tcl command given with the command option will be invoked..TP\fIpathName\fR \fBview\fRReturns the currently selected page. This command is for compatibility with the \fBscrollbar\fR widget..TP\fIpathName\fR \fBview\fR \fIindex\fRSelects the page specified by \fIindex\fR as the currently selected page. This command is for compatibility with the \fBscrollbar\fR widget..TP\fIpathName\fR \fBview\fR \fBmoveto\fR \fIfraction\fRUses the \fIfraction\fR value to determine the corresponding page to move to. This command is for compatibility with the \fBscrollbar\fR widget..TP\fIpathName\fR \fBview\fR \fBscroll\fR \fInum\fR \fIwhat\fRUses the \fInum\fR value to determine how many pages to move forward or backward (\fInum\fR can be negative or positive). The \fIwhat\fR argument is ignored. This command is for compatibility with the \fBscrollbar\fR widget..SH "COMPONENTS".LPGenerally all behavior of the internal components, \fBtabset\fR and \fBnotebook\fR are controlled via the \fBpageconfigure\fR method. The following section documents these two components..LP.nfName: \fBtabset\fRClass: \fBTabset\fR.fi.IPThis is the tabset component. It implements the tabs that are associated with the notebook component..IPSee the "\fBTabset\fR" widget manual entry for details on the \fBtabset\fR component item..LP.nfName: \fBnotebook\fRClass: \fBNotebook\fR.fi.IPThis is the notebook component. It implements the notebook that contains the pages of the tabnotebook..IPSee the "\fBNotebook\fR" widget manual entry for details on the \fBnotebook\fR component item..fi.SH EXAMPLE.PPFollowing is an example that creates a tabnotebook with two pages..PP.nf.IP.ta 2c 8c 12c# Create the tabnotebook widget and pack it. tabnotebook .tn -width 100 -height 100 pack .tn \\ -anchor nw \\ -fill both \\ -expand yes \\ -side left \\ -padx 10 \\ -pady 10.IP# Add two pages to the tabnotebook, # labelled "Page One" and "Page Two" .tn add -label "Page One" .tn add -label "Page Two".IP# Get the child site frames of these two pages. set page1CS [.tn childsite 0] set page2CS [.tn childsite "Page Two"].IP# Create buttons on each page of the tabnotebook. button $page1CS.b -text "Button One" pack $page1CS.b button $page2CS.b -text "Button Two" pack $page2CS.b.IP# Select the first page of the tabnotebook. .tn select 0.fi.SH AUTHORBill W. Scott.SH KEYWORDStab tabset notebook tabnotebook page
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -