Tk Library Source Code

Check-in [6d7e08ad15]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: * doc/mentry.html: Minor improvements. * doc/mentryDateTime.html:
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6d7e08ad15f877b5782e768a6b1569ec533c8fd62e04aab256bbad70fffd116b
User & Date: csaba 2019-05-01 15:32:55
Context
2019-05-01
17:22
* CHANGES.txt: Slightly extended. check-in: f550c7866e user: csaba tags: trunk
15:32
* doc/mentry.html: Minor improvements. * doc/mentryDateTime.html: check-in: 6d7e08ad15 user: csaba tags: trunk
15:32
* doc/mentry.html: Minor improvements. * doc/mentryDateTime.html: check-in: cd2233fc69 user: csaba tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/mentry/doc/mentry.html.

859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
...
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
...
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
...
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
...
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
    <code>"I"</code> stands for&nbsp; <code>"%I:%M %p"</code>&nbsp; or&nbsp;
    <code>"%I:%M:%S %p"</code>&nbsp; (i.e., with AM/PM indicator).&nbsp; The
    procedure expects the separator string (which is usually the
    <code>":"</code> character) as another command-line argument.</li>

    <li class="tm">Finally, the procedure <code><a href=
    "mentryDateTime.html#dateTimeMentry">mentry::dateTimeentry</a></code>
    creates a new mentry widget for displaying and editing a date &amp; time
    according to the format passed to the command as a 5- or 6-character
    string, with the first three characters consisting of the letters
    <code>"d"</code>, <code>"m"</code>, and <code>"y"</code> or
    <code>"Y"</code>, followed by two or three further field descriptor
    characters of the&nbsp; <code>clock format</code>&nbsp; command, which must
    be: <code>"H"</code> or <code>"I"</code>, then <code>"M"</code>, and
    optionally the letter <code>"S"</code>.&nbsp; The procedure expects two
................................................................................
  the file <code>datetime1.tcl</code>, located in the <code>demos</code>
  directory:</p>

  <blockquote>
    <pre>
package require mentry

set title "Date &amp; Time"
wm title . $title 

#
# Add some entries to the Tk option database
#
source [file join [file dirname [info script]] option.tcl]
    
................................................................................
#
array set dateFmts {0 mdy  1 dmy  2 Ymd}
array set dateSeps {0 /    1 .    2 -  }
array set timeFmts {0 IMS  1 HMS}
array set timeSeps {0 :    1 :  }

#
# Choose the date &amp; time formats; don't use the %p field descriptor
# for displaying the AM/PM indicator, because it doesn't work on
# UNIX if Tcl/Tk 8.4 or higher is used in a non-default locale
#
wm withdraw .
set clockVal [clock seconds]
if {[clock format $clockVal -format "%H"] &lt; 12} {
    set meridian AM
................................................................................
                       [clock format $clockVal -format "%Y-%m-%d"]]
set timeIdx [tk_dialog .choice $title "Please choose a time format" {} -1 \
                       [clock format $clockVal -format "%I:%M:%S $meridian"] \
                       [clock format $clockVal -format "%H:%M:%S"]]
wm deiconify .

#   
# Frame .f with mentries displaying the date &amp; time
#   
frame .f
label .f.lDate -text "Date: "
mentry::dateMentry .f.date $dateFmts($dateIdx) $dateSeps($dateIdx) \ 
                   -justify center -background white
frame .f.gap -width 10
label .f.lTime -text "Time: "
................................................................................
  <code>dateFmts</code>, <code>dateSeps</code>, <code>timeFmts</code>, and
  <code>timeSeps</code>.</p>

  <p>The following figure corresponds to the choices&nbsp; <code>dateIdx =
  2</code>&nbsp; and&nbsp; <code>timeIdx = 1</code>:</p>

  <blockquote>
    <img src="datetime1.png" alt="Date &amp; Time" width="279" height="209">
  </blockquote>

  <p>The demo script <code>datetime2.tcl</code> displays both the date and time
  in the same mentry widget, with the aid of the third command described
  above:</p>

  <blockquote>
    <pre>
#
# Frame .f with a mentry displaying the date &amp; time
#
frame .f
label .f.l -text "Date &amp; time: "
mentry::dateTimeMentry .f.me $dateFmts($dateIdx)$timeFmts($timeIdx) \
                       $dateSeps($dateIdx) $timeSeps($timeIdx) \
                       -justify center -background white
pack .f.l .f.me
</pre>
  </blockquote>

  <blockquote>
    <img src="datetime2.png" alt="Date &amp; Time" width="272" height="209">
  </blockquote>

  <p>The Mentry package exports two further commands for date, time, and date
  &amp; time mentries:</p>

  <ul>
    <li>The procedure <code><a href=
    "mentryDateTime.html#putClockVal">mentry::putClockVal</a></code> outputs
    the date, time, or date &amp; time corresponding to an integer clock value
    specified as its first argument to a date, time, or date &amp; time mentry
    widget, passed to it as the second parameter.&nbsp; Like the
    &nbsp;<code>clock format</code>&nbsp; command, the procedure accepts the
    optional argument pair&nbsp; <code>-gmt <i>boolean</i></code>.</li>

    <li class="tm">The procedure <code><a href=
    "mentryDateTime.html#getClockVal">mentry::getClockVal</a></code> returns
    the clock value corresponding to the date, time, or date &amp; time
    contained in the date, time, or date &amp; time mentry specified as its
    first argument.&nbsp; Like the &nbsp;<code>clock scan</code>&nbsp; command,
    the procedure accepts the optional argument pairs&nbsp; <code>-base
    <i>clockValue</i></code>&nbsp; and&nbsp; <code>-gmt
    <i>boolean</i></code>.&nbsp; On failure, the procedure sets the focus to
    the first erronous entry child, generates an error, and returns one of the
    values contained in the following code fragment taken from the scripts
    <code>datetime1.tcl</code> and <code>datetime2.tcl</code>:

      <blockquote>






|







 







|







 







|







 







|







 







|









|


|








|


|
|




|
|






|
|
|
|







859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
...
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
...
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
...
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
...
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
    <code>"I"</code> stands for&nbsp; <code>"%I:%M %p"</code>&nbsp; or&nbsp;
    <code>"%I:%M:%S %p"</code>&nbsp; (i.e., with AM/PM indicator).&nbsp; The
    procedure expects the separator string (which is usually the
    <code>":"</code> character) as another command-line argument.</li>

    <li class="tm">Finally, the procedure <code><a href=
    "mentryDateTime.html#dateTimeMentry">mentry::dateTimeentry</a></code>
    creates a new mentry widget for displaying and editing a date & time
    according to the format passed to the command as a 5- or 6-character
    string, with the first three characters consisting of the letters
    <code>"d"</code>, <code>"m"</code>, and <code>"y"</code> or
    <code>"Y"</code>, followed by two or three further field descriptor
    characters of the&nbsp; <code>clock format</code>&nbsp; command, which must
    be: <code>"H"</code> or <code>"I"</code>, then <code>"M"</code>, and
    optionally the letter <code>"S"</code>.&nbsp; The procedure expects two
................................................................................
  the file <code>datetime1.tcl</code>, located in the <code>demos</code>
  directory:</p>

  <blockquote>
    <pre>
package require mentry

set title "Date & Time"
wm title . $title 

#
# Add some entries to the Tk option database
#
source [file join [file dirname [info script]] option.tcl]
    
................................................................................
#
array set dateFmts {0 mdy  1 dmy  2 Ymd}
array set dateSeps {0 /    1 .    2 -  }
array set timeFmts {0 IMS  1 HMS}
array set timeSeps {0 :    1 :  }

#
# Choose the date & time formats; don't use the %p field descriptor
# for displaying the AM/PM indicator, because it doesn't work on
# UNIX if Tcl/Tk 8.4 or higher is used in a non-default locale
#
wm withdraw .
set clockVal [clock seconds]
if {[clock format $clockVal -format "%H"] &lt; 12} {
    set meridian AM
................................................................................
                       [clock format $clockVal -format "%Y-%m-%d"]]
set timeIdx [tk_dialog .choice $title "Please choose a time format" {} -1 \
                       [clock format $clockVal -format "%I:%M:%S $meridian"] \
                       [clock format $clockVal -format "%H:%M:%S"]]
wm deiconify .

#   
# Frame .f with mentries displaying the date & time
#   
frame .f
label .f.lDate -text "Date: "
mentry::dateMentry .f.date $dateFmts($dateIdx) $dateSeps($dateIdx) \ 
                   -justify center -background white
frame .f.gap -width 10
label .f.lTime -text "Time: "
................................................................................
  <code>dateFmts</code>, <code>dateSeps</code>, <code>timeFmts</code>, and
  <code>timeSeps</code>.</p>

  <p>The following figure corresponds to the choices&nbsp; <code>dateIdx =
  2</code>&nbsp; and&nbsp; <code>timeIdx = 1</code>:</p>

  <blockquote>
    <img src="datetime1.png" alt="Date & Time" width="279" height="209">
  </blockquote>

  <p>The demo script <code>datetime2.tcl</code> displays both the date and time
  in the same mentry widget, with the aid of the third command described
  above:</p>

  <blockquote>
    <pre>
#
# Frame .f with a mentry displaying the date & time
#
frame .f
label .f.l -text "Date & time: "
mentry::dateTimeMentry .f.me $dateFmts($dateIdx)$timeFmts($timeIdx) \
                       $dateSeps($dateIdx) $timeSeps($timeIdx) \
                       -justify center -background white
pack .f.l .f.me
</pre>
  </blockquote>

  <blockquote>
    <img src="datetime2.png" alt="Date & Time" width="272" height="209">
  </blockquote>

  <p>The Mentry package exports two further commands for date, time, and date &
  time mentries:</p>

  <ul>
    <li>The procedure <code><a href=
    "mentryDateTime.html#putClockVal">mentry::putClockVal</a></code> outputs
    the date, time, or date & time corresponding to an integer clock value
    specified as its first argument to a date, time, or date & time mentry
    widget, passed to it as the second parameter.&nbsp; Like the
    &nbsp;<code>clock format</code>&nbsp; command, the procedure accepts the
    optional argument pair&nbsp; <code>-gmt <i>boolean</i></code>.</li>

    <li class="tm">The procedure <code><a href=
    "mentryDateTime.html#getClockVal">mentry::getClockVal</a></code> returns
    the clock value corresponding to the date, time, or date & time contained
    in the date, time, or date & time mentry specified as its first
    argument.&nbsp; Like the &nbsp;<code>clock scan</code>&nbsp; command, the
    procedure accepts the optional argument pairs&nbsp; <code>-base
    <i>clockValue</i></code>&nbsp; and&nbsp; <code>-gmt
    <i>boolean</i></code>.&nbsp; On failure, the procedure sets the focus to
    the first erronous entry child, generates an error, and returns one of the
    values contained in the following code fragment taken from the scripts
    <code>datetime1.tcl</code> and <code>datetime2.tcl</code>:

      <blockquote>

Changes to modules/mentry/doc/mentryDateTime.html.

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
...
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
  <h2 id="dateTimeMentry">The <code><b>mentry::dateTimeMentry</b></code>
  Command</h2>

  <dl>
    <dt><b>NAME</b></dt>

    <dd><code>mentry::dateTimeMentry</code> &ndash; Create and manipulate
    mentry widgets for date &amp; time</dd>

    <dt class="tm"><b>SYNOPSIS</b></dt>

    <dd>
      <pre>
<b>mentry::dateTimeMentry</b> <i>pathName format dateSeparator timeSeparator</i> ?<i>options</i>?
</pre>
    </dd>

    <dt><b>DESCRIPTION</b></dt>

    <dd>This command creates a new mentry widget <code><i>pathName</i></code>
    for displaying and editing a date &amp; time according to the
    <code><i>format</i></code> argument, which must be a string of length 5 or
    6, with the first 3 characters consisting of the letters
    <code><b>"d"</b></code> for the day (<code>01</code> - <code>31</code>),
    <code><b>"m"</b></code> for the month (<code>01</code> - <code>12</code>),
    and <code><b>"y"</b></code> or <code><b>"Y"</b></code> for the year without
    century (<code>00</code> - <code>99</code>) or with century (e.g.,
    <code>2008</code>), in an arbitrary order, followed by 2 or 3 further field
................................................................................

  <h2 id="putClockVal">The <code><b>mentry::putClockVal</b></code> Command</h2>

  <dl>
    <dt><b>NAME</b></dt>

    <dd><code>mentry::putClockVal</code> &ndash; Output a clock value to a
    date, time, or date &amp; time mentry</dd>

    <dt class="tm"><b>SYNOPSIS</b></dt>

    <dd>
      <pre>
<b>mentry::putClockVal</b> <i>clockValue</i> <i>pathName</i> ?<b>-gmt</b> <i>boolean</i>?
</pre>
    </dd>

    <dt><b>DESCRIPTION</b></dt>

    <dd>This command outputs the date, time, or date &amp; time corresponding
    to the integer <code><i>clockValue</i></code> to the mentry widget
    <code><i>pathName</i></code>, which must have been created with the
    <code><b><a href="#dateMentry">mentry::dateMentry</a></b></code>,
    <code><b><a href="#timeMentry">mentry::timeMentry</a></b></code>, or
    <code><b><a href="#dateTimeMentry">mentry::dateTimeMentry</a></b></code>
    command (this is checked by examining the widget's <code><b>type</b></code>
    attribute, which must have the value <code>"Date"</code>,
    <code>"Time"</code>, or <code>"DateTime"</code>).</dd>
................................................................................

  <h2 id="getClockVal">The <code><b>mentry::getClockVal</b></code> Command</h2>

  <dl>
    <dt><b>NAME</b></dt>

    <dd><code>mentry::getClockVal</code> &ndash; Get the clock value from a
    date, time, or date &amp; time mentry</dd>

    <dt class="tm"><b>SYNOPSIS</b></dt>

    <dd>
      <pre>
<b>mentry::getClockVal</b> <i>pathName</i> ?<b>-base</b> <i>clockValue</i>? ?<b>-gmt</b> <i>boolean</i>?
</pre>
    </dd>

    <dt><b>DESCRIPTION</b></dt>

    <dd>This command returns the clock value corresponding to the date, time,
    or date &amp; time contained in the mentry widget
    <code><i>pathName</i></code>, which must have been created with the
    <code><b><a href="#dateMentry">mentry::dateMentry</a></b></code>,
    <code><b><a href="#timeMentry">mentry::timeMentry</a></b></code>, or
    <code><b><a href="#dateTimeMentry">mentry::dateTimeMentry</a></b></code>
    command (this is checked by examining the widget's <code><b>type</b></code>
    attribute, which must have the value <code>"Date"</code>,
    <code>"Time"</code>, or <code>"DateTime"</code>).</dd>

    <dd class="tm">Like in the case of the&nbsp; <code><b>clock
    scan</b></code>&nbsp; command, the optional argument pair&nbsp;
    <code><b>-base</b> <i>clockValue</i></code> specifies that the date
    contained in <code><i>clockValue</i></code> is to be used when getting the
    clock value from the given mentry widget, and the optional argument
    pair&nbsp; <code><b>-gmt</b> <i>boolean</i></code> specifies whether the






|












|







 







|











|
|







 







|












|
|
|
|
|
|
|
|







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
...
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
  <h2 id="dateTimeMentry">The <code><b>mentry::dateTimeMentry</b></code>
  Command</h2>

  <dl>
    <dt><b>NAME</b></dt>

    <dd><code>mentry::dateTimeMentry</code> &ndash; Create and manipulate
    mentry widgets for date & time</dd>

    <dt class="tm"><b>SYNOPSIS</b></dt>

    <dd>
      <pre>
<b>mentry::dateTimeMentry</b> <i>pathName format dateSeparator timeSeparator</i> ?<i>options</i>?
</pre>
    </dd>

    <dt><b>DESCRIPTION</b></dt>

    <dd>This command creates a new mentry widget <code><i>pathName</i></code>
    for displaying and editing a date & time according to the
    <code><i>format</i></code> argument, which must be a string of length 5 or
    6, with the first 3 characters consisting of the letters
    <code><b>"d"</b></code> for the day (<code>01</code> - <code>31</code>),
    <code><b>"m"</b></code> for the month (<code>01</code> - <code>12</code>),
    and <code><b>"y"</b></code> or <code><b>"Y"</b></code> for the year without
    century (<code>00</code> - <code>99</code>) or with century (e.g.,
    <code>2008</code>), in an arbitrary order, followed by 2 or 3 further field
................................................................................

  <h2 id="putClockVal">The <code><b>mentry::putClockVal</b></code> Command</h2>

  <dl>
    <dt><b>NAME</b></dt>

    <dd><code>mentry::putClockVal</code> &ndash; Output a clock value to a
    date, time, or date & time mentry</dd>

    <dt class="tm"><b>SYNOPSIS</b></dt>

    <dd>
      <pre>
<b>mentry::putClockVal</b> <i>clockValue</i> <i>pathName</i> ?<b>-gmt</b> <i>boolean</i>?
</pre>
    </dd>

    <dt><b>DESCRIPTION</b></dt>

    <dd>This command outputs the date, time, or date & time corresponding to
    the integer <code><i>clockValue</i></code> to the mentry widget
    <code><i>pathName</i></code>, which must have been created with the
    <code><b><a href="#dateMentry">mentry::dateMentry</a></b></code>,
    <code><b><a href="#timeMentry">mentry::timeMentry</a></b></code>, or
    <code><b><a href="#dateTimeMentry">mentry::dateTimeMentry</a></b></code>
    command (this is checked by examining the widget's <code><b>type</b></code>
    attribute, which must have the value <code>"Date"</code>,
    <code>"Time"</code>, or <code>"DateTime"</code>).</dd>
................................................................................

  <h2 id="getClockVal">The <code><b>mentry::getClockVal</b></code> Command</h2>

  <dl>
    <dt><b>NAME</b></dt>

    <dd><code>mentry::getClockVal</code> &ndash; Get the clock value from a
    date, time, or date & time mentry</dd>

    <dt class="tm"><b>SYNOPSIS</b></dt>

    <dd>
      <pre>
<b>mentry::getClockVal</b> <i>pathName</i> ?<b>-base</b> <i>clockValue</i>? ?<b>-gmt</b> <i>boolean</i>?
</pre>
    </dd>

    <dt><b>DESCRIPTION</b></dt>

    <dd>This command returns the clock value corresponding to the date, time,
    or date & time contained in the mentry widget <code><i>pathName</i></code>,
    which must have been created with the <code><b><a href=
    "#dateMentry">mentry::dateMentry</a></b></code>, <code><b><a href=
    "#timeMentry">mentry::timeMentry</a></b></code>, or <code><b><a href=
    "#dateTimeMentry">mentry::dateTimeMentry</a></b></code> command (this is
    checked by examining the widget's <code><b>type</b></code> attribute, which
    must have the value <code>"Date"</code>, <code>"Time"</code>, or
    <code>"DateTime"</code>).</dd>

    <dd class="tm">Like in the case of the&nbsp; <code><b>clock
    scan</b></code>&nbsp; command, the optional argument pair&nbsp;
    <code><b>-base</b> <i>clockValue</i></code> specifies that the date
    contained in <code><i>clockValue</i></code> is to be used when getting the
    clock value from the given mentry widget, and the optional argument
    pair&nbsp; <code><b>-gmt</b> <i>boolean</i></code> specifies whether the