Skip to content

Commit 6a95430

Browse files
author
csaba
committed
Merged branch cargo into trunk (see TIP 729).
2 parents 9615205 + 8a08a47 commit 6a95430

File tree

5 files changed

+753
-69
lines changed

5 files changed

+753
-69
lines changed

doc/attribtable.n

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
.\"
2+
.\" Copyright (c) 2025 Csaba Nemethi
3+
.\"
4+
.\" See the file "license.terms" for information on usage and redistribution
5+
.\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6+
.\"
7+
.TH tk attribtable n 9.1 "" Tk "Tk Built-in Commands"
8+
.so man.macros
9+
.BS
10+
'\" Note: do not modify the .SH NAME line immediately below!
11+
.SH NAME
12+
tk attribtable \- Create an attribute table, used to query and modify
13+
arbitrary data attached to any widget.
14+
.SH SYNOPSIS
15+
\fBtk attribtable \fItableName\fR
16+
.BE
17+
.SH DESCRIPTION
18+
.PP
19+
This command creates an attribute table of the name \fItableName\fR,
20+
implemented as a hash table and accessible as a command in the namespace of
21+
the calling context if not fully qualified, and returns the fully qualified
22+
name of the command just created.
23+
.PP
24+
An attribute table is used to query and modify arbitrary data attached to any
25+
widget. These data are commonly called \fIattributes\fR.
26+
.PP
27+
If an attribute table of the given name already exists then it is replaced
28+
with the new one and all the attributes of all widgets set using the old table
29+
instance will be unset.
30+
.PP
31+
\fBREMARK 1:\fR When the \fItableName\fR command is deleted (via \fBrename\fR
32+
\fItableName\fR "" or by deleting the containing namespace), all the
33+
attributes of all widgets set using this command are automatically unset and
34+
the underlying hash table is deleted. This will free all the memory used by
35+
the table.
36+
.PP
37+
\fBREMARK 2:\fR When a widget is destroyed, all of its attributes set by all
38+
attribute table commands are automatically unset. This will free all the
39+
memory used by the widget's attributes.
40+
.PP
41+
The command \fItableName\fR created by this command has the signature
42+
.PP
43+
.CS
44+
\fItableName\fR \fBset\fR|\fBget\fR|\fBunset\fR|\fBclear\fR|\fBexists\fR|\fBnames\fR|\fBpathnames\fR \fIargs\fR
45+
.CE
46+
.PP
47+
In the description of the supported forms below, \fIpathName\fR specifies a
48+
widget whose attributes are being queried or modified via the \fItableName\fR
49+
command.
50+
.\" METHOD: set
51+
.TP
52+
\fItableName\fR \fBset\fR \fIpathName name value\fR ?\fIname value\fR ...?
53+
.
54+
Sets (i.e., adds or updates) the attributes identified by the \fIname\fR
55+
arguments to the values given by the \fIvalue\fR arguments. Returns an empty
56+
string. Example:
57+
.RS
58+
.PP
59+
.CS
60+
# Save and then change the button's text
61+
\fBtk attribtable\fR table
62+
table \fBset\fR .btn prevText [.btn cget -text]
63+
\&.btn configure -text "NewText"
64+
.CE
65+
.RE
66+
.\" METHOD: get
67+
.TP
68+
\fItableName\fR \fBget\fR \fIpathName\fR ?\fIname\fR ?\fIdefaultValue\fR??
69+
.
70+
If \fIname\fR is specified then returns the corresponding attribute value, or
71+
an empty string or \fIdefaultValue\fR (if given) if no corresponding value
72+
exists. Otherwise returns a list consisting of all attribute names and values
73+
of the widget \fIpathName\fR. Example:
74+
.RS
75+
.PP
76+
.CS
77+
# Restore the button's previous text
78+
\&.btn configure -text [table \fBget\fR .btn prevText]
79+
.CE
80+
.RE
81+
.\" METHOD: unset
82+
.TP
83+
\fItableName\fR \fBunset\fR \fIpathName name\fR ?\fIname\fR ...?
84+
.
85+
Unsets the attributes identified by the \fIname\fR arguments. Returns an
86+
empty string. Example:
87+
.RS
88+
.PP
89+
.CS
90+
table \fBunset\fR .btn prevText
91+
.CE
92+
.RE
93+
.\" METHOD: clear
94+
.TP
95+
\fItableName\fR \fBclear\fR \fIpathName\fR
96+
.
97+
Unsets all attributes and removes \fIpathName\fR from the list of those
98+
widgets that have attributes set via \fItableName\fR \fBset\fR. Returns an
99+
empty string. Example:
100+
.RS
101+
.PP
102+
.CS
103+
table \fBclear\fR .btn
104+
.CE
105+
.RE
106+
.\" METHOD: exists
107+
.TP
108+
\fItableName\fR \fBexists\fR \fIpathName\fR ?\fIname\fR?
109+
.
110+
If the optional argument is present then returns \fB1\fR if the attribute
111+
identified by \fIname\fR exists and \fB0\fR otherwise. Without the optional
112+
argument the return value is \fB1\fR if the widget \fIpathName\fR has at
113+
least one attribute set via \fItableName\fR \fBset\fR and \fB0\fR otherwise.
114+
Example:
115+
.RS
116+
.PP
117+
.CS
118+
if [table \fBexists\fR .btn prevText] {
119+
# Restore the button's previous text
120+
\&.btn configure -text [table \fBget\fR .btn prevText]
121+
}
122+
.CE
123+
.RE
124+
.\" METHOD: names
125+
.TP
126+
\fItableName\fR \fBnames\fR \fIpathName\fR
127+
.
128+
Returns a list consisting of all attribute names of the widget
129+
\fIpathName\fR. Example:
130+
.RS
131+
.PP
132+
.CS
133+
puts "attribute names for .btn: [table \fBnames\fR .btn]"
134+
.CE
135+
.RE
136+
.\" METHOD: pathnames
137+
.TP
138+
\fItableName\fR \fBpathnames\fR
139+
.
140+
Returns a list consisting of the path names of all widgets that have
141+
attributes set via \fItableName\fR \fBset\fR.
142+
Example:
143+
.RS
144+
.PP
145+
.CS
146+
puts "widgets in table: [table \fBpathnames\fR]"
147+
.CE
148+
.RE
149+
.SH KEYWORDS
150+
widget, attribute, attribute table
151+
.\" Local Variables:
152+
.\" mode: nroff
153+
.\" fill-column: 78
154+
.\" End:

doc/tk.n

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@ be able to find some options for the application.
4545
If sends have been disabled by deleting the \fBsend\fR command,
4646
this command will reenable them and recreate the \fBsend\fR
4747
command.
48+
.\" METHOD: attribtable
49+
.TP
50+
\fBtk attribtable \fItableName\fR
51+
.
52+
This command creates an attribute table of the name \fItableName\fR as a
53+
command in the namespace of the calling context if not fully qualified. An
54+
attribute table is used to query and modify arbitrary data attached to any
55+
widget. For more details see the \fBattribtable\fR manual page.
4856
.\" METHOD: busy
4957
.TP
5058
\fBtk busy \fIsubcommand\fR ...
5159
.
5260
This command controls the marking of window hierarchies as
5361
.QW busy ,
54-
rendering them non-interactive while some other operation is proceeding. For
62+
rendering them non-interactive while some other operation is proceeding. For
5563
more details see the \fBbusy\fR manual page.
5664
.\" METHOD: caret
5765
.TP
@@ -71,7 +79,7 @@ of the specified \fIwindow\fR if none is given.
7179
\fBtk inactive \fR?\fB\-displayof \fIwindow\fR? ?\fBreset\fR?
7280
.
7381
Returns a positive integer, the number of milliseconds since the last
74-
time the user interacted with the system. If the \fB\-displayof\fR
82+
time the user interacted with the system. If the \fB\-displayof\fR
7583
option is given then the return value refers to the display of
7684
\fIwindow\fR; otherwise it refers to the display of the application's
7785
main window.
@@ -81,23 +89,23 @@ main window.
8189
is not supported by the system, and in safe interpreters.
8290
.PP
8391
If the literal string \fBreset\fR is given as an additional argument,
84-
the timer is reset and an empty string is returned. Resetting the
92+
the timer is reset and an empty string is returned. Resetting the
8593
inactivity time is forbidden in safe interpreters and will throw an
8694
error if tried.
8795
.RE
8896
.\" METHOD: fontchooser
8997
.TP
9098
\fBtk fontchooser \fIsubcommand\fR ...
9199
.
92-
Controls the Tk font selection dialog. For more details see the
100+
Controls the Tk font selection dialog. For more details see the
93101
\fBfontchooser\fR manual page.
94102
.\" METHOD: print
95103
.TP
96104
\fBtk print \fIwindow\fR
97105
.
98106
The \fBtk print\fR command posts a dialog that allows users to print output
99-
from the \fBcanvas\fR and \fBtext\fR widgets. The printing will be done using
100-
platform-native APIs and dialogs where available. For more details see the
107+
from the \fBcanvas\fR and \fBtext\fR widgets. The printing will be done using
108+
platform-native APIs and dialogs where available. For more details see the
101109
\fBprint\fR manual page.
102110
.\" METHOD: scaling
103111
.TP
@@ -127,25 +135,25 @@ accommodate the new scaling factor.
127135
.RE
128136
.\" METHOD: sysnotify
129137
.TP
130-
\fBtk sysnotify \fP \fItitle\fP? \fImessage\fP?
138+
\fBtk sysnotify \fItitle message\fR
131139
.
132140
The \fBtk sysnotify\fP command creates a platform-specific system
133-
notification alert. Its intent is to provide a brief, unobtrusive
141+
notification alert. Its intent is to provide a brief, unobtrusive
134142
notification to the user by popping up a window that briefly appears in a
135-
corner of the screen. For more details see the \fBsysnotify\fR manual page.
143+
corner of the screen. For more details see the \fBsysnotify\fR manual page.
136144
.\" METHOD: systray
137145
.TP
138-
\fBtk systray create\fP \fIsubcommand...\fP
146+
\fBtk systray \fIsubcommand\fR ...
139147
.
140148
The \fBtk systray\fP command creates an icon in the platform-specific
141-
tray. For more details see the \fBsystray\fR manual page.
149+
tray. For more details see the \fBsystray\fR manual page.
142150
.\" METHOD: useinputmethods
143151
.TP
144152
\fBtk useinputmethods \fR?\fB\-displayof \fIwindow\fR? ?\fIboolean\fR?
145153
.
146154
Sets and queries the state of whether Tk should use XIM (X Input Methods)
147155
for filtering events. The resulting state is returned. XIM is used in
148-
some locales (i.e., Japanese, Korean), to handle special input devices. This
156+
some locales (i.e., Japanese, Korean), to handle special input devices. This
149157
feature is only significant on X. If XIM support is not available, this
150158
will always return 0. If the \fIwindow\fR argument is omitted, it defaults
151159
to the main window. If the \fIboolean\fR argument is omitted, the current
@@ -158,9 +166,10 @@ Returns the current Tk windowing system, one of
158166
\fBx11\fR (X11-based), \fBwin32\fR (MS Windows),
159167
or \fBaqua\fR (macOS Aqua).
160168
.SH "SEE ALSO"
161-
busy(n), fontchooser(n), print(n), send(n), sysnotify(n), systray(n), winfo(n)
169+
attribtable(n), busy(n), fontchooser(n), print(n), send(n), sysnotify(n),
170+
systray(n), winfo(n)
162171
.SH KEYWORDS
163-
application name, print, send, sysnotify, systray
172+
application name, attribute, print, send, sysnotify, systray
164173
'\" Local Variables:
165174
'\" mode: nroff
166175
'\" End:

0 commit comments

Comments
 (0)