1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
|
# This file is a Tcl script to test out the "listbox" command
# of Tk. It is organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1993-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
package require tcltest 2.2
eval tcltest::configure $argv
tcltest::loadTestedCommands
namespace import -force tcltest::test
set fixed {Courier -12}
proc record {name args} {
global log
lappend log [format {%s %.6g %.6g} $name {*}$args]
}
proc getsize w {
regexp {(^[^+-]*)} [wm geometry $w] foo x
return $x
}
proc resetGridInfo {} {
# Some window managers, such as mwm, don't reset gridding information
# unless the window is withdrawn and re-mapped. If this procedure
# isn't invoked, the window manager will stay in gridded mode, which
# can cause all sorts of problems. The "wm positionfrom" command is
# needed so that the window manager doesn't ask the user to
# manually position the window when it is re-mapped.
wm withdraw .
wm positionfrom . user
wm deiconify .
}
# Procedure that creates a second listbox for checking things related
# to partially visible lines.
proc mkPartial {{w .partial}} {
destroy $w
toplevel $w
wm geometry $w +0+0
listbox $w.l -width 30 -height 5
pack $w.l -expand 1 -fill both
$w.l insert end one two three four five six seven eight nine ten \
eleven twelve thirteen fourteen fifteen
update
scan [wm geometry $w] "%dx%d" width height
wm geometry $w ${width}x[expr $height-3]
update
}
# Create entries in the option database to be sure that geometry options
# like border width have predictable values.
option add *Listbox.borderWidth 2
option add *Listbox.highlightThickness 2
option add *Listbox.font {Helvetica -12 bold}
# Listbox used in 3.* configuration options tests
listbox .l
pack .l
update
resetGridInfo
test listbox-1.1 {configuration options} -body {
.l configure -activestyle under
list [lindex [.l configure -activestyle] 4] [.l cget -activestyle]
} -cleanup {
.l configure -activestyle [lindex [.l configure -activestyle] 3]
} -result {underline underline}
test listbox-1.2 {configuration options} -body {
.l configure -activestyle foo
} -returnCodes error -result {bad activestyle "foo": must be dotbox, none, or underline}
test listbox-1.3 {configuration options} -body {
.l configure -background #ff0000
list [lindex [.l configure -background] 4] [.l cget -background]
} -cleanup {
.l configure -background [lindex [.l configure -background] 3]
} -result {{#ff0000} #ff0000}
test listbox-1.4 {configuration options} -body {
.l configure -background non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test listbox-1.5 {configuration options} -body {
.l configure -bd 4
list [lindex [.l configure -bd] 4] [.l cget -bd]
} -cleanup {
.l configure -bd [lindex [.l configure -bd] 3]
} -result {4 4}
test listbox-1.6 {configuration options} -body {
.l configure -bd badValue
} -returnCodes error -result {bad screen distance "badValue"}
test listbox-1.7 {configuration options} -body {
.l configure -bg #ff0000
list [lindex [.l configure -bg] 4] [.l cget -bg]
} -cleanup {
.l configure -bg [lindex [.l configure -bg] 3]
} -result {{#ff0000} #ff0000}
test listbox-1.8 {configuration options} -body {
.l configure -bg non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test listbox-1.9 {configuration options} -body {
.l configure -borderwidth 1.3
list [lindex [.l configure -borderwidth] 4] [.l cget -borderwidth]
} -cleanup {
.l configure -borderwidth [lindex [.l configure -borderwidth] 3]
} -result {1 1}
test listbox-1.10 {configuration options} -body {
.l configure -borderwidth badValue
} -returnCodes error -result {bad screen distance "badValue"}
test listbox-1.11 {configuration options} -body {
.l configure -cursor arrow
list [lindex [.l configure -cursor] 4] [.l cget -cursor]
} -cleanup {
.l configure -cursor [lindex [.l configure -cursor] 3]
} -result {arrow arrow}
test listbox-1.12 {configuration options} -body {
.l configure -cursor badValue
} -returnCodes error -result {bad cursor spec "badValue"}
test listbox-1.13 {configuration options} -body {
.l configure -disabledforeground #110022
list [lindex [.l configure -disabledforeground] 4] [.l cget -disabledforeground]
} -cleanup {
.l configure -disabledforeground [lindex [.l configure -disabledforeground] 3]
} -result {{#110022} #110022}
test listbox-1.14 {configuration options} -body {
.l configure -disabledforeground bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-1.15 {configuration options} -body {
.l configure -exportselection yes
list [lindex [.l configure -exportselection] 4] [.l cget -exportselection]
} -cleanup {
.l configure -exportselection [lindex [.l configure -exportselection] 3]
} -result {1 1}
test listbox-1.16 {configuration options} -body {
.l configure -exportselection xyzzy
} -returnCodes error -result {expected boolean value but got "xyzzy"}
test listbox-1.17 {configuration options} -body {
.l configure -fg #110022
list [lindex [.l configure -fg] 4] [.l cget -fg]
} -cleanup {
.l configure -fg [lindex [.l configure -fg] 3]
} -result {{#110022} #110022}
test listbox-1.18 {configuration options} -body {
.l configure -fg bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-1.19 {configuration options} -body {
.l configure -font {Helvetica 12}
list [lindex [.l configure -font] 4] [.l cget -font]
} -cleanup {
.l configure -font [lindex [.l configure -font] 3]
} -result {{Helvetica 12} {Helvetica 12}}
test listbox-1.21 {configuration options} -body {
.l configure -foreground #110022
list [lindex [.l configure -foreground] 4] [.l cget -foreground]
} -cleanup {
.l configure -foreground [lindex [.l configure -foreground] 3]
} -result {{#110022} #110022}
test listbox-1.22 {configuration options} -body {
.l configure -foreground bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-1.23 {configuration options} -body {
.l configure -height 30
list [lindex [.l configure -height] 4] [.l cget -height]
} -cleanup {
.l configure -height [lindex [.l configure -height] 3]
} -result {30 30}
test listbox-1.24 {configuration options} -body {
.l configure -height 20p
} -returnCodes error -result {expected integer but got "20p"}
test listbox-1.25 {configuration options} -body {
.l configure -highlightbackground #112233
list [lindex [.l configure -highlightbackground] 4] [.l cget -highlightbackground]
} -cleanup {
.l configure -highlightbackground [lindex [.l configure -highlightbackground] 3]
} -result {{#112233} #112233}
test listbox-1.26 {configuration options} -body {
.l configure -highlightbackground ugly
} -returnCodes error -result {unknown color name "ugly"}
test listbox-1.27 {configuration options} -body {
.l configure -highlightcolor #123456
list [lindex [.l configure -highlightcolor] 4] [.l cget -highlightcolor]
} -cleanup {
.l configure -highlightcolor [lindex [.l configure -highlightcolor] 3]
} -result {{#123456} #123456}
test listbox-1.28 {configuration options} -body {
.l configure -highlightcolor bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-1.29 {configuration options} -body {
.l configure -highlightthickness 6
list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness]
} -cleanup {
.l configure -highlightthickness [lindex [.l configure -highlightthickness] 3]
} -result {6 6}
test listbox-1.30 {configuration options} -body {
.l configure -highlightthickness bogus
} -returnCodes error -result {bad screen distance "bogus"}
test listbox-1.31 {configuration options} -body {
.l configure -highlightthickness -2
list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness]
} -cleanup {
.l configure -highlightthickness [lindex [.l configure -highlightthickness] 3]
} -result {0 0}
test listbox-1.32.1 {configuration options} -setup {
set res {}
} -body {
.l configure -justify left
set res [list [lindex [.l configure -justify] 4] [.l cget -justify]]
.l configure -justify center
lappend res [lindex [.l configure -justify] 4] [.l cget -justify]
.l configure -justify right
lappend res [lindex [.l configure -justify] 4] [.l cget -justify]
} -cleanup {
.l configure -justify [lindex [.l configure -justify] 3]
} -result {left left center center right right}
test listbox-1.32.2 {configuration options} -body {
.l configure -justify bogus
} -returnCodes error -result {bad justification "bogus": must be left, right, or center}
test listbox-1.33 {configuration options} -body {
.l configure -relief groove
list [lindex [.l configure -relief] 4] [.l cget -relief]
} -cleanup {
.l configure -relief [lindex [.l configure -relief] 3]
} -result {groove groove}
test listbox-1.34 {configuration options} -body {
.l configure -relief 1.5
} -returnCodes error -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
test listbox-1.35 {configuration options} -body {
.l configure -selectbackground #110022
list [lindex [.l configure -selectbackground] 4] [.l cget -selectbackground]
} -cleanup {
.l configure -selectbackground [lindex [.l configure -selectbackground] 3]
} -result {{#110022} #110022}
test listbox-1.36 {configuration options} -body {
.l configure -selectbackground bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-1.37 {configuration options} -body {
.l configure -selectborderwidth 1.3
list [lindex [.l configure -selectborderwidth] 4] [.l cget -selectborderwidth]
} -cleanup {
.l configure -selectborderwidth [lindex [.l configure -selectborderwidth] 3]
} -result {1 1}
test listbox-1.38 {configuration options} -body {
.l configure -selectborderwidth badValue
} -returnCodes error -result {bad screen distance "badValue"}
test listbox-1.39 {configuration options} -body {
.l configure -selectforeground #654321
list [lindex [.l configure -selectforeground] 4] [.l cget -selectforeground]
} -cleanup {
.l configure -selectforeground [lindex [.l configure -selectforeground] 3]
} -result {{#654321} #654321}
test listbox-1.40 {configuration options} -body {
.l configure -selectforeground bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-1.41 {configuration options} -body {
.l configure -selectmode string
list [lindex [.l configure -selectmode] 4] [.l cget -selectmode]
} -cleanup {
.l configure -selectmode [lindex [.l configure -selectmode] 3]
} -result {string string}
test listbox-1.43 {configuration options} -body {
.l configure -setgrid false
list [lindex [.l configure -setgrid] 4] [.l cget -setgrid]
} -cleanup {
.l configure -setgrid [lindex [.l configure -setgrid] 3]
} -result {0 0}
test listbox-1.44 {configuration options} -body {
.l configure -setgrid lousy
} -returnCodes error -result {expected boolean value but got "lousy"}
test listbox-1.45 {configuration options} -body {
.l configure -state disabled
list [lindex [.l configure -state] 4] [.l cget -state]
} -cleanup {
.l configure -state [lindex [.l configure -state] 3]
} -result {disabled disabled}
test listbox-1.46 {configuration options} -body {
.l configure -state foo
} -returnCodes error -result {bad state "foo": must be disabled or normal}
test listbox-1.47 {configuration options} -body {
.l configure -takefocus {any string}
list [lindex [.l configure -takefocus] 4] [.l cget -takefocus]
} -cleanup {
.l configure -takefocus [lindex [.l configure -takefocus] 3]
} -result {{any string} {any string}}
test listbox-1.49 {configuration options} -body {
.l configure -width 45
list [lindex [.l configure -width] 4] [.l cget -width]
} -cleanup {
.l configure -width [lindex [.l configure -width] 3]
} -result {45 45}
test listbox-1.50 {configuration options} -body {
.l configure -width 3p
} -returnCodes error -result {expected integer but got "3p"}
test listbox-1.51 {configuration options} -body {
.l configure -xscrollcommand {Some command}
list [lindex [.l configure -xscrollcommand] 4] [.l cget -xscrollcommand]
} -cleanup {
.l configure -xscrollcommand [lindex [.l configure -xscrollcommand] 3]
} -result {{Some command} {Some command}}
test listbox-1.53 {configuration options} -body {
.l configure -yscrollcommand {Another command}
list [lindex [.l configure -yscrollcommand] 4] [.l cget -yscrollcommand]
} -cleanup {
.l configure -yscrollcommand [lindex [.l configure -yscrollcommand] 3]
} -result {{Another command} {Another command}}
test listbox-1.55 {configuration options} -body {
.l configure -listvar testVariable
list [lindex [.l configure -listvar] 4] [.l cget -listvar]
} -cleanup {
.l configure -listvar [lindex [.l configure -listvar] 3]
} -result {testVariable testVariable}
test listbox-2.1 {Tk_ListboxCmd procedure} -body {
listbox
} -returnCodes error -result {wrong # args: should be "listbox pathName ?-option value ...?"}
test listbox-2.2 {Tk_ListboxCmd procedure} -body {
listbox gorp
} -returnCodes error -result {bad window path name "gorp"}
test listbox-2.3 {Tk_ListboxCmd procedure} -setup {
destroy .l
} -body {
listbox .l
list [winfo exists .l] [winfo class .l] [info commands .l]
} -result {1 Listbox .l}
test listbox-2.4 {Tk_ListboxCmd procedure} -setup {
destroy .l
} -body {
listbox .l -gorp foo
} -cleanup {
destroy .l
} -returnCodes error -result {unknown option "-gorp"}
test listbox-2.4.1 {Tk_ListboxCmd procedure} -setup {
destroy .l
} -body {
catch {listbox .l -gorp foo}
list [winfo exists .l] [info commands .l]
} -cleanup {
destroy .l
} -result {0 {}}
test listbox-2.5 {Tk_ListboxCmd procedure} -setup {
destroy .l
} -body {
listbox .l
} -cleanup {
destroy .l
} -result {.l}
# Listbox used in 3.1 -3.115 tests
destroy .l
listbox .l -width 20 -height 5 -bd 4 -highlightthickness 1 -selectborderwidth 2
pack .l
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11 el12 el13 el14 \
el15 el16 el17
update
test listbox-3.1 {ListboxWidgetCmd procedure} -body {
.l
} -returnCodes error -result {wrong # args: should be ".l option ?arg ...?"}
test listbox-3.2 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate
} -returnCodes error -result {wrong # args: should be ".l activate index"}
test listbox-3.3 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate a b
} -returnCodes error -result {wrong # args: should be ".l activate index"}
test listbox-3.4 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate fooey
} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}
test listbox-3.5 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate 3
.l index active
} -result 3
test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate -1
.l index active
} -result {0}
test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate 30
.l index active
} -result {17}
test listbox-3.8 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate end
.l index active
} -result {17}
test listbox-3.9 {ListboxWidgetCmd procedure, "bbox" option} -body {
.l bbox
} -returnCodes error -result {wrong # args: should be ".l bbox index"}
test listbox-3.10 {ListboxWidgetCmd procedure, "bbox" option} -body {
.l bbox a b
} -returnCodes error -result {wrong # args: should be ".l bbox index"}
test listbox-3.11 {ListboxWidgetCmd procedure, "bbox" option} -body {
.l bbox fooey
} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}
test listbox-3.12 {ListboxWidgetCmd procedure, "bbox" option} -body {
.l yview 3
update
list [.l bbox 2] [.l bbox 8]
} -result {{} {}}
test listbox-3.13 {ListboxWidgetCmd procedure, "bbox" option} -cleanup {
destroy .l2
} -body {
# Used to generate a core dump before a bug was fixed (the last
# element would be on-screen if it existed, but it doesn't exist).
listbox .l2
pack .l2 -side top
tkwait visibility .l2
set x [.l2 bbox 0]
destroy .l2
set x
} -cleanup {
destroy .l2
} -result {}
test listbox-3.14 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
fonts
} -body {
.l yview 3
update
list [.l bbox 3] [.l bbox 4]
} -result {{7 7 17 14} {7 26 17 14}}
test listbox-3.15 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
fonts
} -body {
.l yview 0
update
list [.l bbox -1] [.l bbox 0]
} -result {{} {7 7 17 14}}
test listbox-3.16 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
fonts
} -body {
.l yview end
update
list [.l bbox 17] [.l bbox end] [.l bbox 18]
} -result {{7 83 24 14} {7 83 24 14} {}}
test listbox-3.17 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
fonts
} -setup {
destroy .t
} -body {
toplevel .t
wm geom .t +0+0
listbox .t.l -width 10 -height 5
.t.l insert 0 "Short" "Somewhat longer" "Really, quite a whole lot longer than can possibly fit on the screen" "Short"
pack .t.l
update
.t.l xview moveto .2
.t.l bbox 2
} -cleanup {
destroy .t
} -result {-72 39 393 14}
test listbox-3.18 {ListboxWidgetCmd procedure, "bbox" option, partial last line} -constraints {
fonts
} -body {
mkPartial
list [.partial.l bbox 3] [.partial.l bbox 4]
} -result {{5 56 24 14} {5 73 23 14}}
test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body {
.l cget
} -returnCodes error -result {wrong # args: should be ".l cget option"}
test listbox-3.20 {ListboxWidgetCmd procedure, "cget" option} -body {
.l cget a b
} -returnCodes error -result {wrong # args: should be ".l cget option"}
test listbox-3.21 {ListboxWidgetCmd procedure, "cget" option} -body {
.l cget -gorp
} -returnCodes error -result {unknown option "-gorp"}
test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} -body {
.l cget -setgrid
} -result {0}
test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} -body {
llength [.l configure]
} -result {28}
test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} -body {
.l configure -gorp
} -returnCodes error -result {unknown option "-gorp"}
test listbox-3.25 {ListboxWidgetCmd procedure, "configure" option} -body {
.l configure -setgrid
} -result {-setgrid setGrid SetGrid 0 0}
test listbox-3.26 {ListboxWidgetCmd procedure, "configure" option} -body {
.l configure -gorp is_messy
} -returnCodes error -result {unknown option "-gorp"}
test listbox-3.27 {ListboxWidgetCmd procedure, "configure" option} -body {
set oldbd [.l cget -bd]
set oldht [.l cget -highlightthickness]
.l configure -bd 3 -highlightthickness 0
set x "[.l cget -bd] [.l cget -highlightthickness]"
.l configure -bd $oldbd -highlightthickness $oldht
set x
} -result {3 0}
test listbox-3.28 {ListboxWidgetCmd procedure, "curselection" option} -body {
.l curselection a
} -returnCodes error -result {wrong # args: should be ".l curselection"}
test listbox-3.29 {ListboxWidgetCmd procedure, "curselection" option} -body {
.l selection clear 0 end
.l selection set 3 6
.l selection set 9
.l curselection
} -result {3 4 5 6 9}
test listbox-3.30 {ListboxWidgetCmd procedure, "delete" option} -body {
.l delete
} -returnCodes error -result {wrong # args: should be ".l delete firstIndex ?lastIndex?"}
test listbox-3.31 {ListboxWidgetCmd procedure, "delete" option} -body {
.l delete a b c
} -returnCodes error -result {wrong # args: should be ".l delete firstIndex ?lastIndex?"}
test listbox-3.32 {ListboxWidgetCmd procedure, "delete" option} -body {
.l delete badIndex
} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}
test listbox-3.33 {ListboxWidgetCmd procedure, "delete" option} -body {
.l delete 2 123ab
} -returnCodes error -result {bad listbox index "123ab": must be active, anchor, end, @x,y, or a number}
test listbox-3.34 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 3
list [.l2 get 2] [.l2 get 3] [.l2 index end]
} -cleanup {
destroy .l2
} -result {el2 el4 7}
test listbox-3.35 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 2 4
list [.l2 get 1] [.l2 get 2] [.l2 index end]
} -cleanup {
destroy .l2
} -result {el1 el5 5}
test listbox-3.36 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete -3 2
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {el3 el4 el5 el6 el7}
test listbox-3.37 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete -3 -1
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {el0 el1 el2 el3 el4 el5 el6 el7}
test listbox-3.38 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 2 end
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {el0 el1}
test listbox-3.39 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 5 20
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {el0 el1 el2 el3 el4}
test listbox-3.40 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete end 20
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {el0 el1 el2 el3 el4 el5 el6}
test listbox-3.41 {ListboxWidgetCmd procedure, "delete" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 8 20
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {el0 el1 el2 el3 el4 el5 el6 el7}
test listbox-3.42 {ListboxWidgetCmd procedure, "get" option} -body {
.l get
} -returnCodes error -result {wrong # args: should be ".l get firstIndex ?lastIndex?"}
test listbox-3.43 {ListboxWidgetCmd procedure, "get" option} -body {
.l get a b c
} -returnCodes error -result {wrong # args: should be ".l get firstIndex ?lastIndex?"}
test listbox-3.44 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 2.4
} -returnCodes error -result {bad listbox index "2.4": must be active, anchor, end, @x,y, or a number}
test listbox-3.45 {ListboxWidgetCmd procedure, "get" option} -body {
.l get end bogus
} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}
test listbox-3.46 {ListboxWidgetCmd procedure, "get" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
list [.l2 get 0] [.l2 get 3] [.l2 get end]
} -cleanup {
destroy .l2
} -result {el0 el3 el7}
test listbox-3.47 {ListboxWidgetCmd procedure, "get" option} -setup {
destroy .l2
} -body {
listbox .l2
list [.l2 get 0] [.l2 get end]
} -cleanup {
destroy .l2
} -result {{} {}}
test listbox-3.48 {ListboxWidgetCmd procedure, "get" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 "two words" el4 el5 el6 el7
.l2 get 3 end
} -cleanup {
destroy .l2
} -result {{two words} el4 el5 el6 el7}
test listbox-3.49 {ListboxWidgetCmd procedure, "get" option} -body {
.l get -1
} -result {}
test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} -body {
.l get -2 -1
} -result {}
test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} -body {
.l get -2 3
} -result {el0 el1 el2 el3}
test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 12 end
} -result {el12 el13 el14 el15 el16 el17}
test listbox-3.53 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 12 20
} -result {el12 el13 el14 el15 el16 el17}
test listbox-3.54 {ListboxWidgetCmd procedure, "get" option} -body {
.l get end
} -result {el17}
test listbox-3.55 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 30
} -result {}
test listbox-3.56 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 30 35
} -result {}
test listbox-3.57 {ListboxWidgetCmd procedure, "index" option} -body {
.l index
} -returnCodes error -result {wrong # args: should be ".l index index"}
test listbox-3.58 {ListboxWidgetCmd procedure, "index" option} -body {
.l index a b
} -returnCodes error -result {wrong # args: should be ".l index index"}
test listbox-3.59 {ListboxWidgetCmd procedure, "index" option} -body {
.l index @
} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or a number}
test listbox-3.60 {ListboxWidgetCmd procedure, "index" option} -body {
.l index 2
} -result 2
test listbox-3.61 {ListboxWidgetCmd procedure, "index" option} -body {
.l index -1
} -result {-1}
test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} -body {
.l index end
} -result 18
test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} -body {
.l index 34
} -result 34
test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} -body {
.l insert
} -returnCodes error -result {wrong # args: should be ".l insert index ?element ...?"}
test listbox-3.65 {ListboxWidgetCmd procedure, "insert" option} -body {
.l insert badIndex
} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}
test listbox-3.66 {ListboxWidgetCmd procedure, "insert" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert end a b c d e
.l2 insert 3 x y z
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {a b c x y z d e}
test listbox-3.67 {ListboxWidgetCmd procedure, "insert" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert end a b c
.l2 insert -1 x
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {x a b c}
test listbox-3.68 {ListboxWidgetCmd procedure, "insert" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert end a b c
.l2 insert end x
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {a b c x}
test listbox-3.69 {ListboxWidgetCmd procedure, "insert" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert end a b c
.l2 insert 43 x
.l2 get 0 end
} -cleanup {
destroy .l2
} -result {a b c x}
test listbox-3.70 {ListboxWidgetCmd procedure, "nearest" option} -body {
.l nearest
} -returnCodes error -result {wrong # args: should be ".l nearest y"}
test listbox-3.71 {ListboxWidgetCmd procedure, "nearest" option} -body {
.l nearest a b
} -returnCodes error -result {wrong # args: should be ".l nearest y"}
test listbox-3.72 {ListboxWidgetCmd procedure, "nearest" option} -body {
.l nearest 20p
} -returnCodes error -result {expected integer but got "20p"}
test listbox-3.73 {ListboxWidgetCmd procedure, "nearest" option} -body {
.l yview 3
.l nearest 1000
} -result {7}
test listbox-3.74 {ListboxWidgetCmd procedure, "scan" option} -body {
.l scan a b
} -returnCodes error -result {wrong # args: should be ".l scan mark|dragto x y"}
test listbox-3.75 {ListboxWidgetCmd procedure, "scan" option} -body {
.l scan a b c d
} -returnCodes error -result {wrong # args: should be ".l scan mark|dragto x y"}
test listbox-3.76 {ListboxWidgetCmd procedure, "scan" option} -body {
.l scan foo bogus 2
} -returnCodes error -result {expected integer but got "bogus"}
test listbox-3.77 {ListboxWidgetCmd procedure, "scan" option} -body {
.l scan foo 2 2.3
} -returnCodes error -result {expected integer but got "2.3"}
test listbox-3.78 {ListboxWidgetCmd procedure, "scan" option} -constraints {
fonts
} -setup {
destroy .t
} -body {
toplevel .t
wm geom .t +0+0
listbox .t.l -width 10 -height 5
.t.l insert 0 "Short" "Somewhat longer" "Really, quite a whole lot longer than can possibly fit on the screen" "Short" a b c d e f g h i j
pack .t.l
update
.t.l scan mark 100 140
.t.l scan dragto 90 137
update
list [format {%.6g %.6g} {*}[.t.l xview]] [format {%.6g %.6g} {*}[.t.l yview]]
} -cleanup {
destroy .t
} -result {{0.249364 0.427481} {0.0714286 0.428571}}
test listbox-3.79 {ListboxWidgetCmd procedure, "scan" option} -body {
.l scan foo 2 4
} -returnCodes error -result {bad option "foo": must be mark or dragto}
test listbox-3.80 {ListboxWidgetCmd procedure, "see" option} -body {
.l see
} -returnCodes error -result {wrong # args: should be ".l see index"}
test listbox-3.81 {ListboxWidgetCmd procedure, "see" option} -body {
.l see a b
} -returnCodes error -result {wrong # args: should be ".l see index"}
test listbox-3.82 {ListboxWidgetCmd procedure, "see" option} -body {
.l see gorp
} -returnCodes error -result {bad listbox index "gorp": must be active, anchor, end, @x,y, or a number}
test listbox-3.83 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 7
.l index @0,0
} -result {7}
test listbox-3.84 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 11
.l index @0,0
} -result {7}
test listbox-3.85 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 6
.l index @0,0
} -result {6}
test listbox-3.86 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 5
.l index @0,0
} -result {3}
test listbox-3.87 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 12
.l index @0,0
} -result {8}
test listbox-3.88 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 13
.l index @0,0
} -result {11}
test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see -1
.l index @0,0
} -result {0}
test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see end
.l index @0,0
} -result {13}
test listbox-3.91 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 322
.l index @0,0
} -result {13}
test listbox-3.92 {ListboxWidgetCmd procedure, "see" option, partial last line} -body {
mkPartial
.partial.l see 4
.partial.l index @0,0
} -result {1}
test listbox-3.93 {ListboxWidgetCmd procedure, "selection" option} -body {
.l select a
} -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"}
test listbox-3.94 {ListboxWidgetCmd procedure, "selection" option} -body {
.l select a b c d
} -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"}
test listbox-3.95 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection a bogus
} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}
test listbox-3.96 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection a 0 lousy
} -returnCodes error -result {bad listbox index "lousy": must be active, anchor, end, @x,y, or a number}
test listbox-3.97 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor 0 0
} -returnCodes error -result {wrong # args: should be ".l selection anchor index"}
test listbox-3.98 {ListboxWidgetCmd procedure, "selection" option} -body {
list [.l selection anchor 5; .l index anchor] \
[.l selection anchor 0; .l index anchor]
} -result {5 0}
test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor -1
.l index anchor
} -result {0}
test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor end
.l index anchor
} -result {17}
test listbox-3.101 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor 44
.l index anchor
} -result {17}
test listbox-3.102 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2 8
.l selection clear 3 4
.l curselection
} -result {2 5 6 7 8}
test listbox-3.103 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection includes 0 0
} -returnCodes error -result {wrong # args: should be ".l selection includes index"}
test listbox-3.104 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2 8
.l selection clear 4
list [.l selection includes 3] [.l selection includes 4] \
[.l selection includes 5]
} -result {1 0 1}
test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection set 0 end
.l selection includes -1
} -result {0}
test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set end
.l selection includes end
} -result {1}
test listbox-3.107 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection set 0 end
.l selection includes 44
} -result {0}
test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 selection includes 0
} -cleanup {
destroy .l2
} -result {0}
test listbox-3.109 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2
.l selection set 5 7
.l curselection
} -result {2 5 6 7}
test listbox-3.110 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2
.l selection set 5 7
.l selection set 5 7
.l curselection
} -result {2 5 6 7}
test listbox-3.111 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection badOption 0 0
} -returnCodes error -result {bad option "badOption": must be anchor, clear, includes, or set}
test listbox-3.112 {ListboxWidgetCmd procedure, "size" option} -body {
.l size a
} -returnCodes error -result {wrong # args: should be ".l size"}
test listbox-3.113 {ListboxWidgetCmd procedure, "size" option} -body {
.l size
} -result {18}
test listbox-3.114 {ListboxWidgetCmd procedure, "xview" option} -setup {
destroy .l2
} -body {
listbox .l2
update
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0 1}
test listbox-3.115 {ListboxWidgetCmd procedure, "xview" option} -setup {
destroy .l2
} -body {
listbox .l2 -width 10 -height 5 -font $fixed
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
pack .l2
update
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0 1}
test listbox-3.116 {ListboxWidgetCmd procedure, "xview" option} -constraints {
fonts
} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
.l2 xview 4
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0.08 0.28}
test listbox-3.117 {ListboxWidgetCmd procedure, "xview" option} -body {
.l xview foo
} -returnCodes error -result {expected integer but got "foo"}
test listbox-3.118 {ListboxWidgetCmd procedure, "xview" option} -body {
.l xview zoom a b
} -returnCodes error -result {unknown option "zoom": must be moveto or scroll}
test listbox-3.119 {ListboxWidgetCmd procedure, "xview" option} -constraints {
fonts
} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
.l xview 0
.l2 xview moveto .4
update
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0.4 0.6}
test listbox-3.120 {ListboxWidgetCmd procedure, "xview" option} -constraints {
fonts
} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
.l2 xview 0
.l2 xview scroll 2 units
update
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0.04 0.24}
test listbox-3.121 {ListboxWidgetCmd procedure, "xview" option} -constraints {
fonts
} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
.l2 xview 30
.l2 xview scroll -1 pages
update
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0.44 0.64}
test listbox-3.122 {ListboxWidgetCmd procedure, "xview" option} -constraints {
fonts
} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
.l2 configure -width 1
update
.l2 xview 30
.l2 xview scroll -4 pages
update
format {%.6g %.6g} {*}[.l2 xview]
} -cleanup {
destroy .l2
} -result {0.52 0.54}
test listbox-3.123 {ListboxWidgetCmd procedure, "yview" option} -setup {
destroy .l2
} -body {
listbox .l2
pack .l2
update
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0 1}
test listbox-3.124 {ListboxWidgetCmd procedure, "yview" option} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 el1
pack .l2
update
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0 1}
test listbox-3.125 {ListboxWidgetCmd procedure, "yview" option} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 yview 4
update
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0.2 0.45}
test listbox-3.126 {ListboxWidgetCmd procedure, "yview" option, partial last line} -setup {
destroy .l
listbox .l -width 10 -height 5 -font $fixed
pack .l
update
} -body {
.l insert 0 a b c d e f g h i j k l m n o p q r s t
mkPartial
format {%.6g %.6g} {*}[.partial.l yview]
} -cleanup {
destroy .l
} -result {0 0.266667}
# Listbox used in 3.127 -3.137 tests
destroy .l
listbox .l -width 20 -height 5 -bd 4 -highlightthickness 1 -selectborderwidth 2
pack .l
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11 el12 el13 el14 \
el15 el16 el17
update
test listbox-3.127 {ListboxWidgetCmd procedure, "xview" option} -body {
.l yview foo
} -returnCodes error -result {bad listbox index "foo": must be active, anchor, end, @x,y, or a number}
test listbox-3.128 {ListboxWidgetCmd procedure, "xview" option} -body {
.l yview foo a b
} -returnCodes error -result {unknown option "foo": must be moveto or scroll}
test listbox-3.129 {ListboxWidgetCmd procedure, "xview" option} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 yview 0
.l2 yview moveto .31
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0.3 0.55}
test listbox-3.130 {ListboxWidgetCmd procedure, "xview" option} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 yview 2
.l2 yview scroll 2 pages
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0.4 0.65}
test listbox-3.131 {ListboxWidgetCmd procedure, "xview" option} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 yview 10
.l2 yview scroll -3 units
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0.35 0.6}
test listbox-3.132 {ListboxWidgetCmd procedure, "xview" option} -setup {
destroy .l2
listbox .l2 -width 10 -height 5 -font $fixed
pack .l2
update
} -body {
.l2 insert 0 a b c d e f g h i j k l m n o p q r s t
.l2 configure -height 2
update
.l2 yview 15
.l2 yview scroll -4 pages
format {%.6g %.6g} {*}[.l2 yview]
} -cleanup {
destroy .l2
} -result {0.55 0.65}
test listbox-3.133 {ListboxWidgetCmd procedure, "xview" option} -body {
.l whoknows
} -returnCodes error -result {bad option "whoknows": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
test listbox-3.134 {ListboxWidgetCmd procedure, "xview" option} -body {
.l c
} -returnCodes error -result {ambiguous option "c": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
test listbox-3.135 {ListboxWidgetCmd procedure, "xview" option} -body {
.l in
} -returnCodes error -result {ambiguous option "in": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
test listbox-3.136 {ListboxWidgetCmd procedure, "xview" option} -body {
.l s
} -returnCodes error -result {ambiguous option "s": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
test listbox-3.137 {ListboxWidgetCmd procedure, "xview" option} -body {
.l se
} -returnCodes error -result {ambiguous option "se": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
# No tests for DestroyListbox: I can't come up with anything to test
# in this procedure.
test listbox-4.1 {ConfigureListbox procedure} -constraints {
fonts
} -setup {
deleteWindows
destroy .l
listbox .l -setgrid 1 -width 25 -height 15
pack .l
update
} -body {
set x [getsize .]
.l configure -setgrid 0
update
list $x [getsize .]
} -cleanup {
deleteWindows
} -result {25x15 185x263}
resetGridInfo
test listbox-4.2 {ConfigureListbox procedure} -setup {
deleteWindows
destroy .l
listbox .l -setgrid 1 -width 25 -height 15
pack .l
update
} -body {
.l configure -highlightthickness -3
.l cget -highlightthickness
} -cleanup {
deleteWindows
} -result {0}
test listbox-4.3 {ConfigureListbox procedure} -setup {
deleteWindows
destroy .l
listbox .l -setgrid 1 -width 25 -height 15
pack .l
update
} -body {
.l configure -exportselection 0
.l delete 0 end
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
.l selection set 3 5
.l configure -exportselection 1
selection get
} -cleanup {
deleteWindows
} -result {el3
el4
el5}
test listbox-4.4 {ConfigureListbox procedure} -setup {
deleteWindows
listbox .l -setgrid 1 -width 25 -height 15
pack .l
update
} -body {
entry .e
.e insert 0 abc
.e select from 0
.e select to 2
.l configure -exportselection 0
.l delete 0 end
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
.l selection set 3 5
.l selection clear 3 5
.l configure -exportselection 1
list [selection own] [selection get]
} -cleanup {
deleteWindows
} -result {.e ab}
test listbox-4.5 {-exportselection option} -setup {
deleteWindows
listbox .l -setgrid 1 -width 25 -height 15
pack .l
update
} -body {
selection clear .
.l configure -exportselection 1
.l delete 0 end
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
.l selection set 1 1
set x {}
lappend x [catch {selection get} msg] $msg [.l curselection]
.l config -exportselection 0
lappend x [catch {selection get} msg] $msg [.l curselection]
.l selection clear 0 end
lappend x [catch {selection get} msg] $msg [.l curselection]
.l selection set 1 3
lappend x [catch {selection get} msg] $msg [.l curselection]
.l config -exportselection 1
lappend x [catch {selection get} msg] $msg [.l curselection]
} -cleanup {
deleteWindows
} -result {0 el1 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {} 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {1 2 3} 0 {el1
el2
el3} {1 2 3}}
test listbox-4.6 {ConfigureListbox procedure} -constraints {
fonts
} -setup {
deleteWindows
} -body {
# The following code (reset geometry, withdraw, etc.) is necessary
# to reset the state of some window managers like olvwm under
# SunOS 4.1.3.
wm geom . 300x300
update
wm geom . {}
wm withdraw .
listbox .l2 -font $fixed -width 15 -height 20
pack .l2
update
wm deiconify .
set x [getsize .]
.l2 configure -setgrid 1
update
list $x [getsize .]
} -cleanup {
deleteWindows
} -result {115x328 15x20}
test listbox-4.7 {ConfigureListbox procedure} -setup {
deleteWindows
} -body {
wm withdraw .
listbox .l2 -font $fixed -width 30 -height 20 -setgrid 1
wm geom . +25+25
pack .l2
update
wm deiconify .
set result [getsize .]
wm geom . 26x15
update
lappend result [getsize .]
.l2 configure -setgrid 1
update
lappend result [getsize .]
} -cleanup {
deleteWindows
wm geom . {}
} -result {30x20 26x15 26x15}
resetGridInfo
test listbox-4.8 {ConfigureListbox procedure} -setup {
destroy .l2
} -body {
listbox .l2 -width 15 -height 20 -xscrollcommand "record x" \
-yscrollcommand "record y"
pack .l2
update
.l2 configure -fg black
set log {}
update
set log
} -cleanup {
destroy .l2
} -result {{y 0 1} {x 0 1}}
test listbox-4.9 {ConfigureListbox procedure, -listvar} -setup {
destroy .l2
} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 get 0 end
} -cleanup {
destroy .l2
} -result [list a b c d]
test listbox-4.10 {ConfigureListbox, no listvar -> existing listvar} -setup {
destroy .l2
} -body {
set x [list a b c d]
listbox .l2
.l2 insert end 1 2 3 4
.l2 configure -listvar x
.l2 get 0 end
} -cleanup {
destroy .l2
} -result [list a b c d]
test listbox-4.11 {ConfigureListbox procedure, listvar -> no listvar} -setup {
destroy .l2
} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 configure -listvar {}
.l2 insert end 1 2 3 4
list $x [.l2 get 0 end]
} -cleanup {
destroy .l2
} -result [list [list a b c d] [list a b c d 1 2 3 4]]
test listbox-4.12 {ConfigureListbox procedure, listvar -> different listvar} -setup {
destroy .l2
} -body {
set x [list a b c d]
set y [list 1 2 3 4]
listbox .l2
.l2 configure -listvar x
.l2 configure -listvar y
.l2 insert end 5 6 7 8
list $x $y
} -cleanup {
destroy .l2
} -result [list [list a b c d] [list 1 2 3 4 5 6 7 8]]
test listbox-4.13 {ConfigureListbox, no listvar -> non-existant listvar} -setup {
destroy .l2
} -body {
catch {unset x}
listbox .l2
.l2 insert end a b c d
.l2 configure -listvar x
set x
} -cleanup {
destroy .l2
} -result [list a b c d]
test listbox-4.14 {ConfigureListbox, non-existant listvar} -setup {
destroy .l2
} -body {
catch {unset x}
listbox .l2 -listvar x
list [info exists x] $x
} -cleanup {
destroy .l2
} -result [list 1 {}]
test listbox-4.15 {ConfigureListbox, listvar -> non-existant listvar} -setup {
destroy .l2
} -body {
catch {unset y}
set x [list a b c d]
listbox .l2 -listvar x
.l2 configure -listvar y
list [info exists y] $y
} -cleanup {
destroy .l2
} -result [list 1 [list a b c d]]
test listbox-4.16 {ConfigureListbox, listvar -> same listvar} -setup {
destroy .l2
} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 configure -listvar x
set x
} -cleanup {
destroy .l2
} -result [list a b c d]
test listbox-4.17 {ConfigureListbox, no listvar -> no listvar} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert end a b c d
.l2 configure -listvar {}
.l2 get 0 end
} -cleanup {
destroy .l2
} -result [list a b c d]
test listbox-4.18 {ConfigureListbox, no listvar -> bad listvar} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert end a b c d
set x "this is a \" bad list"
catch {.l2 configure -listvar x} result
list [.l2 get 0 end] [.l2 cget -listvar] $result
} -cleanup {
destroy .l2
} -result [list [list a b c d] {} \
"unmatched open quote in list: invalid -listvariable value"]
test listbox-4.19 {ConfigureListbox, no listvar -> bad non-existent listvar} -setup {
destroy .l2
} -body {
unset -nocomplain ::foo
listbox .l2 -listvar foo
.l2 insert end a b c d
catch {.l2 configure -listvar ::zoo::bar::foo} result
list [.l2 get 0 end] [.l2 cget -listvar] $foo $result
} -cleanup {
destroy .l2
} -result [list [list a b c d] foo [list a b c d] \
{can't set "::zoo::bar::foo": parent namespace doesn't exist}]
# No tests for DisplayListbox: I don't know how to test this procedure.
test listbox-5.1 {ListboxComputeGeometry procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -font $fixed -width 15 -height 20
pack .l
list [winfo reqwidth .l] [winfo reqheight .l]
} -result {115 328}
test listbox-5.2 {ListboxComputeGeometry procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -font $fixed -width 0 -height 10
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
} -result {17 168}
test listbox-5.3 {ListboxComputeGeometry procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -font $fixed -width 0 -height 10 -bd 3
.l insert 0 Short "Really much longer" Longer
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
} -result {138 170}
test listbox-5.4 {ListboxComputeGeometry procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -font $fixed -width 10 -height 0
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
} -result {80 24}
test listbox-5.5 {ListboxComputeGeometry procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -font $fixed -width 10 -height 0 -highlightthickness 0
.l insert 0 Short "Really much longer" Longer
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
} -result {76 52}
test listbox-5.6 {ListboxComputeGeometry procedure} -setup {
destroy .l
} -body {
# If "0" in selected font had 0 width, caused divide-by-zero error.
pack [listbox .l -font {{open look glyph}}]
update
} -cleanup {
destroy .l
} -result {}
# Listbox used in 6.*, 7.* tests
destroy .l
listbox .l -height 2 -xscrollcommand "record x" -yscrollcommand "record y"
pack .l
update
test listbox-6.1 {InsertEls procedure} -body {
.l delete 0 end
.l insert end a b c d
.l insert 5 x y z
.l insert 2 A
.l insert 0 q r s
.l get 0 end
} -result {q r s a b A c d x y z}
test listbox-6.2 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l insert 2 A B
.l index anchor
} -result {4}
test listbox-6.3 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l insert 3 A B
.l index anchor
} -result {2}
test listbox-6.4 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l insert 2 A B
.l index @0,0
} -result {5}
test listbox-6.5 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l insert 3 A B
.l index @0,0
} -result {3}
test listbox-6.6 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 5
.l insert 5 A B
.l index active
} -result {7}
test listbox-6.7 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 5
.l insert 6 A B
.l index active
} -result {5}
test listbox-6.8 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c
.l index active
} -result {2}
test listbox-6.9 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0
.l index active
} -result {0}
test listbox-6.10 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b "two words" c d e f g h i j
update
set log {}
.l insert 0 word
update
set log
} -result {{y 0 0.166667}}
test listbox-6.11 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b "two words" c d e f g h i j
update
set log {}
.l insert 0 "much longer entry"
update
set log
} -result {{y 0 0.166667} {x 0 1}}
test listbox-6.12 {InsertEls procedure} -constraints {
fonts
} -setup {
destroy .l2
} -body {
listbox .l2 -width 0 -height 0
pack .l2 -side top
.l2 insert 0 a b "two words" c d
set x {}
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
.l2 insert 0 "much longer entry"
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
} -cleanup {
destroy .l2
} -result {80 93 122 110}
test listbox-6.13 {InsertEls procedure, check -listvar update} -setup {
destroy .l2
} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 insert 0 1 2 3 4
set x
} -cleanup {
destroy .l2
} -result [list 1 2 3 4 a b c d]
test listbox-6.14 {InsertEls procedure, check selection update} -setup {
destroy .l2
} -body {
listbox .l2
.l2 insert 0 0 1 2 3 4
.l2 selection set 2 4
.l2 insert 0 a
.l2 curselection
} -cleanup {
destroy .l2
} -result [list 3 4 5]
test listbox-6.15 {InsertEls procedure, lost namespaced listvar} -body {
destroy .l2
namespace eval test { variable foo {a b} }
listbox .l2 -listvar ::test::foo
namespace delete test
.l2 insert end c d
.l2 delete end
.l2 insert end e f
catch {set ::test::foo} result
list [.l2 get 0 end] [.l2 cget -listvar] $result
} -cleanup {
destroy .l2
} -result [list [list a b c e f] ::test::foo \
{can't read "::test::foo": no such variable}]
test listbox-7.1 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection set 1 6
.l delete 4 3
list [.l size] [selection get]
} -result {10 {b
c
d
e
f
g}}
test listbox-7.2 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection set 3 6
.l delete 4 4
list [.l size] [.l get 4] [.l curselection]
} -result {9 f {3 4 5}}
test listbox-7.3 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l delete 0 3
list [.l size] [.l get 0] [.l get 1]
} -result {6 e f}
test listbox-7.4 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l delete 8 1000
list [.l size] [.l get 7]
} -result {8 h}
test listbox-7.5 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l delete 0 1
.l index anchor
} -result {0}
test listbox-7.6 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l delete 2
.l index anchor
} -result {2}
test listbox-7.7 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 4
.l delete 2 5
.l index anchor
} -result {2}
test listbox-7.8 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 3
.l delete 4 5
.l index anchor
} -result {3}
test listbox-7.9 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 1 2
.l index @0,0
} -result {1}
test listbox-7.10 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 3 4
.l index @0,0
} -result {3}
test listbox-7.11 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 4 6
.l index @0,0
} -result {3}
test listbox-7.12 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 3 end
.l index @0,0
} -result {1}
test listbox-7.13 {DeleteEls procedure, updating view with partial last line} -body {
mkPartial
.partial.l yview 8
update
.partial.l delete 10 13
.partial.l index @0,0
} -result {7}
test listbox-7.14 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 3 4
.l index active
} -result {4}
test listbox-7.15 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 5 7
.l index active
} -result {5}
test listbox-7.16 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 5 end
.l index active
} -result {4}
test listbox-7.17 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 0 end
.l index active
} -result {0}
test listbox-7.18 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" d e f g h i j
update
set log {}
.l delete 4 6
update
set log
} -result {{y 0 0.25}}
test listbox-7.19 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" d e f g h i j
update
set log {}
.l delete 3
update
set log
} -result {{y 0 0.2} {x 0 1}}
test listbox-7.20 {DeleteEls procedure} -constraints {
fonts
} -setup {
destroy .l2
} -body {
listbox .l2 -width 0 -height 0
pack .l2 -side top
.l2 insert 0 a b "two words" c d e f g
set x {}
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
.l2 delete 2 4
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
} -result {80 144 17 93}
test listbox-7.21 {DeleteEls procedure, check -listvar update} -setup {
destroy .l2
} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 delete 0 1
set x
} -result [list c d]
test listbox-8.1 {ListboxEventProc procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -setgrid 1
pack .l
update
set x [getsize .]
destroy .l
list $x [getsize .] [winfo exists .l] [info command .l]
} -cleanup {
destroy .l
} -result {20x10 150x178 0 {}}
resetGridInfo
test listbox-8.2 {ListboxEventProc procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
listbox .l -height 5 -width 10
.l insert 0 a b c "A string that is very very long" d e f g h i j k
pack .l
update
place .l -width 50 -height 80
update
list [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]]
} -cleanup {
destroy .l
} -result {{0 0.222222} {0 0.333333}}
test listbox-8.3 {ListboxEventProc procedure} -setup {
deleteWindows
} -body {
listbox .l1 -bg #543210
rename .l1 .l2
set x {}
lappend x [winfo children .]
lappend x [.l2 cget -bg]
destroy .l1
lappend x [info command .l*] [winfo children .]
} -cleanup {
deleteWindows
} -result {.l1 #543210 {} {}}
test listbox-9.1 {ListboxCmdDeletedProc procedure} -setup {
deleteWindows
} -body {
listbox .l1
rename .l1 {}
list [info command .l*] [winfo children .]
} -cleanup {
deleteWindows
} -result {{} {}}
test listbox-9.2 {ListboxCmdDeletedProc procedure, disabling -setgrid} -constraints {
fonts
} -setup {
destroy .top
} -body {
toplevel .top
wm geom .top +0+0
listbox .top.l -setgrid 1 -width 20 -height 10
pack .top.l
update
set x [getsize .top]
rename .top.l {}
update
lappend x [getsize .top]
} -cleanup {
destroy .top
} -result {20x10 150x178}
# Listbox used in 10.* tests
destroy .l
test listbox-10.1 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l activate 3
update
list [.l activate 3; .l index active] [.l activate 6; .l index active]
} -cleanup {
destroy .l
} -result {3 6}
test listbox-10.2 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l selection anchor 2
update
.l index anchor
} -cleanup {
destroy .l
} -result 2
test listbox-10.3 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l insert end A B C D E
.l selection anchor end
update
.l delete 12 end
list [.l index anchor] [.l index end]
} -cleanup {
destroy .l
} -result {12 12}
test listbox-10.4 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index a
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "a": must be active, anchor, end, @x,y, or a number}
test listbox-10.5 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index end
} -cleanup {
destroy .l
} -result {12}
test listbox-10.6 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l get end
} -cleanup {
destroy .l
} -result {el11}
test listbox-10.7 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l delete 0 end
update
.l index end
} -cleanup {
destroy .l
} -result 0
test listbox-10.8 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index @
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or a number}
test listbox-10.9 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index @foo
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "@foo": must be active, anchor, end, @x,y, or a number}
test listbox-10.10 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index @1x3
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "@1x3": must be active, anchor, end, @x,y, or a number}
test listbox-10.11 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index @1,
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "@1,": must be active, anchor, end, @x,y, or a number}
test listbox-10.12 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index @1,foo
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "@1,foo": must be active, anchor, end, @x,y, or a number}
test listbox-10.13 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index @1,2x
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "@1,2x": must be active, anchor, end, @x,y, or a number}
test listbox-10.14 {GetListboxIndex procedure} -constraints {
fonts
} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
list [.l index @5,57] [.l index @5,58]
} -cleanup {
.l delete 0 end
} -cleanup {
destroy .l
} -result {3 3}
test listbox-10.15 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index 1xy
} -cleanup {
destroy .l
} -returnCodes error -result {bad listbox index "1xy": must be active, anchor, end, @x,y, or a number}
test listbox-10.16 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index 3
} -cleanup {
destroy .l
} -result {3}
test listbox-10.17 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index 20
} -cleanup {
destroy .l
} -result {20}
test listbox-10.18 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l get 20
} -cleanup {
destroy .l
} -result {}
test listbox-10.19 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
update
.l index -2
} -cleanup {
destroy .l
} -result -2
test listbox-10.20 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
pack [listbox .l]
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l delete 0 end
update
.l index 1
} -cleanup {
destroy .l
} -result 1
test listbox-11.1 {ChangeListboxView procedure, boundary conditions for index} -setup {
destroy .l
} -body {
listbox .l -height 5
pack .l
.l insert 0 a b c d e f g h i j
.l yview 3
update
set x [.l index @0,0]
.l yview -1
update
lappend x [.l index @0,0]
} -cleanup {
destroy .l
} -result {3 0}
test listbox-11.2 {ChangeListboxView procedure, boundary conditions for index} -setup {
destroy .l
} -body {
listbox .l -height 5
pack .l
.l insert 0 a b c d e f g h i j
.l yview 3
update
set x [.l index @0,0]
.l yview 20
update
lappend x [.l index @0,0]
} -cleanup {
destroy .l
} -result {3 5}
test listbox-11.3 {ChangeListboxView procedure} -setup {
destroy .l
} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
.l insert 0 a b c d e f g h i j
update
set log {}
.l yview 2
update
list [format {%.6g %.6g} {*}[.l yview]] $log
} -cleanup {
destroy .l
} -result {{0.2 0.7} {{y 0.2 0.7}}}
test listbox-11.4 {ChangeListboxView procedure} -setup {
destroy .l
} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
.l insert 0 a b c d e f g h i j
update
set log {}
.l yview 8
update
list [format {%.6g %.6g} {*}[.l yview]] $log
} -cleanup {
destroy .l
} -result {{0.5 1} {{y 0.5 1}}}
test listbox-11.5 {ChangeListboxView procedure} -setup {
destroy .l
} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
.l insert 0 a b c d e f g h i j
.l yview 3
update
set log {}
.l yview 3
update
list [format {%.6g %.6g} {*}[.l yview]] $log
} -cleanup {
destroy .l
} -result {{0.3 0.8} {}}
test listbox-11.6 {ChangeListboxView procedure, partial last line} -body {
mkPartial
.partial.l yview 13
.partial.l index @0,0
} -cleanup {
destroy .l
} -result {11}
# Listbox used in 12.* tests
destroy .l
listbox .l -font $fixed -xscrollcommand "record x" -width 10
.l insert 0 0123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789
pack .l
update
test listbox-12.1 {ChangeListboxOffset procedure} -constraints {
fonts
} -body {
set log {}
.l xview 99
update
list [format {%.6g %.6g} {*}[.l xview]] $log
} -result {{0.9 1} {{x 0.9 1}}}
test listbox-12.2 {ChangeListboxOffset procedure} -constraints {
fonts
} -body {
set log {}
.l xview 99
.l xview moveto -.25
update
list [format {%.6g %.6g} {*}[.l xview]] $log
} -result {{0 0.1} {{x 0 0.1}}}
test listbox-12.3 {ChangeListboxOffset procedure} -constraints {
fonts
} -body {
.l xview 10
update
set log {}
.l xview 10
update
list [format {%.6g %.6g} {*}[.l xview]] $log
} -result {{0.1 0.2} {}}
# Listbox used in 13.* tests
destroy .l
listbox .l -font $fixed -width 10 -height 5
pack .l
.l insert 0 a bb c d e f g h i j k l m n o p q r s
.l insert 0 0123456789a123456789b123456789c123456789d123456789
update
set width [expr [lindex [.l bbox 2] 2] - [lindex [.l bbox 1] 2]]
set height [expr [lindex [.l bbox 2] 1] - [lindex [.l bbox 1] 1]]
test listbox-13.1 {ListboxScanTo procedure} -constraints {
fonts
} -body {
.l yview 0
.l xview 0
.l scan mark 10 20
.l scan dragto [expr 10-$width] [expr 20-$height]
update
list [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]]
} -result {{0.2 0.4} {0.5 0.75}}
test listbox-13.2 {ListboxScanTo procedure} -constraints {
fonts
} -body {
.l yview 5
.l xview 10
.l scan mark 10 20
.l scan dragto 20 40
update
set x [list [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]]]
.l scan dragto [expr 20-$width] [expr 40-$height]
update
lappend x [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]]
} -result {{0 0.2} {0 0.25} {0.2 0.4} {0.5 0.75}}
test listbox-13.3 {ListboxScanTo procedure} -constraints {
fonts
} -body {
.l yview moveto 1.0
.l xview moveto 1.0
.l scan mark 10 20
.l scan dragto 5 10
update
set x [list [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]]]
.l scan dragto [expr 5+$width] [expr 10+$height]
update
lappend x [format {%.6g %.6g} {*}[.l xview]] [format {%.6g %.6g} {*}[.l yview]]
} -result {{0.8 1} {0.75 1} {0.64 0.84} {0.25 0.5}}
test listbox-14.1 {NearestListboxElement procedure, partial last line} -body {
mkPartial
.partial.l nearest [winfo height .partial.l]
} -result {4}
# Listbox used in 14.* tests
destroy .l
listbox .l -font $fixed -width 20 -height 10
.l insert 0 a b c d e f g h i j k l m n o p q r s t
.l yview 4
pack .l
update
test listbox-14.2 {NearestListboxElement procedure} -constraints {
fonts
} -body {
.l index @50,0
} -result {4}
test listbox-14.3 {NearestListboxElement procedure} -constraints {
fonts
} -body {
list [.l index @50,35] [.l index @50,36]
} -result {5 6}
test listbox-14.4 {NearestListboxElement procedure} -constraints {
fonts
} -body {
.l index @50,200
} -result {13}
# Listbox used in 15.* 16.* and 17.* tests
destroy .l
listbox .l -font $fixed -width 20 -height 10
pack .l
update
test listbox-15.1 {ListboxSelect procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j k l m n o p
.l select set 2 4
.l select set 7 12
.l select clear 4 7
.l curselection
} -result {2 3 8 9 10 11 12}
test listbox-15.2 {ListboxSelect procedure} -setup {
destroy .e
} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j k l m n o p
entry .e
.e insert 0 "This is some text"
.e select from 0
.e select to 7
.l selection clear 2 4
set x [selection own]
.l selection set 3
list $x [selection own] [selection get]
} -cleanup {
destroy .e
} -result {.e .l d}
test listbox-15.3 {ListboxSelect procedure} -body {
.l delete 0 end
.l selection clear 0 end
.l select set 0 end
.l curselection
} -result {}
test listbox-15.4 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set -2 -1
.l curselection
} -result {}
test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set -1 3
.l curselection
} -result {0 1 2 3}
test listbox-15.6 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 2 4
.l curselection
} -result {2 3 4}
test listbox-15.7 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 4 end
.l curselection
} -result {4 5}
test listbox-15.8 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 4 30
.l curselection
} -result {4 5}
test listbox-15.9 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set end 30
.l curselection
} -result {5}
test listbox-15.10 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 20 25
.l curselection
} -result {}
test listbox-16.1 {ListboxFetchSelection procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" e f g h i \\ k l m n o p
.l selection set 2 4
.l selection set 9
.l selection set 11 12
selection get
} -result "c\ntwo words\ne\n\\\nl\nm"
test listbox-16.2 {ListboxFetchSelection procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" e f g h i \\ k l m n o p
.l selection set 3
selection get
} -result "two words"
test listbox-16.3 {ListboxFetchSelection procedure, retrieve in several parts} -body {
set long "This is quite a long string\n"
append long $long $long $long $long
append long $long $long $long $long
append long $long $long
.l delete 0 end
.l insert 0 1$long 2$long 3$long 4$long 5$long
.l selection set 0 end
set sel [selection get]
string compare 1$long\n2$long\n3$long\n4$long\n5$long $sel
} -cleanup {
catch {unset long sel}
} -result {0}
test listbox-17.1 {ListboxLostSelection procedure} -setup {
destroy .e
} -body {
.l delete 0 end
.l insert 0 a b c d e
.l select set 0 end
entry .e
.e insert 0 "This is some text"
.e select from 0
.e select to 5
.l curselection
} -cleanup {
destroy .e
} -result {}
test listbox-17.2 {ListboxLostSelection procedure} -setup {
destroy .e
} -body {
.l delete 0 end
.l insert 0 a b c d e
.l select set 0 end
.l configure -exportselection 0
entry .e
.e insert 0 "This is some text"
.e select from 0
.e select to 5
.l curselection
} -cleanup {
destroy .e
} -result {0 1 2 3 4}
# Listbox used in 18.* tests
destroy .l
listbox .l -font $fixed -width 10 -height 5
pack .l
update
test listbox-18.1 {ListboxUpdateVScrollbar procedure} -body {
.l configure -yscrollcommand "record y"
set log {}
.l insert 0 a b c
update
.l insert end d e f g h
update
.l delete 0 end
update
set log
} -result {{y 0 1} {y 0 0.625} {y 0 1}}
test listbox-18.2 {ListboxUpdateVScrollbar procedure, partial last line} -body {
mkPartial
.partial.l configure -yscrollcommand "record y"
set log {}
.partial.l yview 3
update
set log
} -result {{y 0.2 0.466667}}
test listbox-18.3 {ListboxUpdateVScrollbar procedure} -body {
proc bgerror args {
global x errorInfo
set x [list $args $errorInfo]
}
.l configure -yscrollcommand gorp
.l insert 0 foo
update
set x
} -cleanup {
rename bgerror {}
} -result {{{invalid command name "gorp"}} {invalid command name "gorp"
while executing
"gorp 0.0 1.0"
(vertical scrolling command executed by listbox)}}
# Listbox used in 19.* tests
destroy .l
listbox .l -font $fixed -width 10 -height 5
pack .l
update
test listbox-19.1 {ListboxUpdateVScrollbar procedure} -constraints {
fonts
} -body {
.l configure -xscrollcommand "record x"
set log {}
.l insert 0 abc
update
.l insert 0 "This is a much longer string..."
update
.l delete 0 end
update
set log
} -result {{x 0 1} {x 0 0.322581} {x 0 1}}
test listbox-19.2 {ListboxUpdateVScrollbar procedure} -body {
proc bgerror args {
global x errorInfo
set x [list $args $errorInfo]
}
.l configure -xscrollcommand bogus
.l insert 0 foo
update
set x
} -result {{{invalid command name "bogus"}} {invalid command name "bogus"
while executing
"bogus 0.0 1.0"
(horizontal scrolling command executed by listbox)}}
test listbox-20.1 {listbox vs hidden commands} -setup {
deleteWindows
} -body {
set l [interp hidden]
listbox .l
interp hide {} .l
destroy .l
set res1 [list [winfo children .] [interp hidden]]
set res2 [list {} $l]
expr {$res1 eq $res2}
} -result 1
# tests for ListboxListVarProc
test listbox-21.1 {ListboxListVarProc} -setup {
destroy .l
} -body {
catch {unset x}
listbox .l -listvar x
set x [list a b c d]
.l get 0 end
} -cleanup {
destroy .l
} -result [list a b c d]
test listbox-21.2 {ListboxListVarProc} -setup {
destroy .l
} -body {
set x [list a b c d]
listbox .l -listvar x
unset x
set x
} -cleanup {
destroy .l
} -result [list a b c d]
test listbox-21.3 {ListboxListVarProc} -setup {
destroy .l
} -body {
set x [list a b c d]
listbox .l -listvar x
.l configure -listvar {}
unset x
info exists x
} -cleanup {
destroy .l
} -result 0
test listbox-21.4 {ListboxListVarProc} -setup {
destroy .l
} -body {
set x [list a b c d]
listbox .l -listvar x
lappend x e f g
.l size
} -cleanup {
destroy .l
} -result 7
test listbox-21.5 {ListboxListVarProc, test selection after listvar mod} -setup {
destroy .l
} -body {
set x [list a b c d e f g]
listbox .l -listvar x
.l selection set end
set x [list a b c d]
set x [list 0 1 2 3 4 5 6]
.l curselection
} -cleanup {
destroy .l
} -result {}
test listbox-21.6 {ListboxListVarProc, test selection after listvar mod} -setup {
destroy .l
} -body {
set x [list a b c d]
listbox .l -listvar x
.l selection set 3
lappend x e f g
.l curselection
} -cleanup {
destroy .l
} -result 3
test listbox-21.7 {ListboxListVarProc, test selection after listvar mod} -setup {
destroy .l
} -body {
set x [list a b c d]
listbox .l -listvar x
.l selection set 0
set x [linsert $x 0 1 2 3 4]
.l curselection
} -cleanup {
destroy .l
} -result 0
test listbox-21.8 {ListboxListVarProc, test selection after listvar mod} -setup {
destroy .l
} -body {
set x [list a b c d]
listbox .l -listvar x
.l selection set 2
set x [list a b c]
.l curselection
} -cleanup {
destroy .l
} -result 2
test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
destroy .l
} -body {
catch {unset x}
set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
pack .l
update
lappend x "0000000000"
update
lappend x "00000000000000000000"
update
set log
} -cleanup {
destroy .l
} -result [list {x 0 1} {x 0 1} {x 0 0.5}]
test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
destroy .l
} -body {
catch {unset x}
set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
pack .l
update
lappend x "0000000000"
update
lappend x "00000000000000000000"
update
set x [list "0000000000"]
update
set log
} -cleanup {
destroy .l
} -result [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}]
test listbox-21.11 {ListboxListVarProc, bad list} -setup {
destroy .l
} -body {
catch {unset x}
listbox .l -listvar x
set x [list a b c d]
catch {set x "this is a \" bad list"} result
set result
} -cleanup {
destroy .l
} -result {can't set "x": invalid listvar value}
test listbox-21.12 {ListboxListVarProc, cleanup item attributes} -setup {
destroy .l
} -body {
set x [list a b c d e f g]
listbox .l -listvar x
.l itemconfigure end -fg red
set x [list a b c d]
set x [list 0 1 2 3 4 5 6]
.l itemcget end -fg
} -cleanup {
destroy .l
} -result {}
test listbox-21.12a {ListboxListVarProc, cleanup item attributes} -setup {
destroy .l
} -body {
set x [list a b c d e f g]
listbox .l -listvar x
.l itemconfigure end -fg red
set x [list a b c d]
set x [list 0 1 2 3 4 5 6]
.l itemcget end -fg
} -cleanup {
destroy .l
} -result {}
test listbox-21.13 {listbox item configurations and listvar based deletions} -setup {
destroy .l
} -body {
catch {unset x}
listbox .l -listvar x
.l insert end a b c
.l itemconfigure 1 -fg red
set x [list b c]
.l itemcget 1 -fg
} -cleanup {
destroy .l
} -result red
test listbox-21.14 {listbox item configurations and listvar based inserts} -setup {
destroy .l
} -body {
catch {unset x}
listbox .l -listvar x
.l insert end a b c
.l itemconfigure 0 -fg red
set x [list 1 2 3 4 a b c]
.l itemcget 0 -fg
} -cleanup {
destroy .l
} -result red
test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} -setup {
destroy .l
} -body {
catch {unset x}
set log {}
listbox .l -listvar x -yscrollcommand "record y" -font fixed -height 3
pack .l
update
lappend x a b c d e f
update
set log
} -cleanup {
destroy .l
} -result [list {y 0 1} {y 0 0.5}]
test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup {
destroy .l
} -body {
catch {unset x}
listbox .l -listvar x -height 3
pack .l
update
set x [list 0 1 2 3 4 5]
.l yview scroll 3 units
update
set result {}
lappend result [format {%.6g %.6g} {*}[.l yview]]
set x [lreplace $x 3 3]
set x [lreplace $x 3 3]
set x [lreplace $x 3 3]
update
lappend result [format {%.6g %.6g} {*}[.l yview]]
set result
} -cleanup {
destroy .l
} -result [list {0.5 1} {0 1}]
# UpdateHScrollbar
test listbox-22.1 {UpdateHScrollbar} -setup {
destroy .l
} -body {
set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x"
pack .l
update
.l insert end "0000000000"
update
.l insert end "00000000000000000000"
update
set log
} -cleanup {
destroy .l
} -result [list {x 0 1} {x 0 1} {x 0 0.5}]
# ConfigureListboxItem
test listbox-23.1 {ConfigureListboxItem} -setup {
destroy .l
} -body {
listbox .l
catch {.l itemconfigure 0} result
set result
} -cleanup {
destroy .l
} -result {item number "0" out of range}
test listbox-23.2 {ConfigureListboxItem} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c d
.l itemconfigure 0
} -cleanup {
destroy .l
} -result [list {-background background Background {} {}} \
{-bg -background} \
{-fg -foreground} \
{-foreground foreground Foreground {} {}} \
{-selectbackground selectBackground Foreground {} {}} \
{-selectforeground selectForeground Background {} {}}]
test listbox-23.3 {ConfigureListboxItem, itemco shortcut} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c d
.l itemco 0 -background
} -cleanup {
destroy .l
} -result {-background background Background {} {}}
test listbox-23.4 {ConfigureListboxItem, wrong num args} -setup {
destroy .l
} -body {
listbox .l
.l insert end a
catch {.l itemco} result
set result
} -cleanup {
destroy .l
} -result {wrong # args: should be ".l itemconfigure index ?-option? ?value? ?-option value ...?"}
test listbox-23.5 {ConfigureListboxItem, multiple calls} -setup {
destroy .l
} -body {
listbox .l
set i 0
foreach color {red orange yellow green blue white violet} {
.l insert end $color
.l itemconfigure $i -bg $color
incr i
}
pack .l
update
list [.l itemcget 0 -bg] [.l itemcget 1 -bg] [.l itemcget 2 -bg] \
[.l itemcget 3 -bg] [.l itemcget 4 -bg] [.l itemcget 5 -bg] \
[.l itemcget 6 -bg]
} -cleanup {
destroy .l
} -result {red orange yellow green blue white violet}
# Listbox used in 23.6 -23.17 tests
destroy .l
listbox .l
.l insert end a b c d
test listbox-23.6 {configuration options} -body {
.l itemconfigure 0 -background #ff0000
list [lindex [.l itemconfigure 0 -background] 4] [.l itemcget 0 -background]
} -cleanup {
.l configure -background #ffffff
} -result {{#ff0000} #ff0000}
test listbox-23.7 {configuration options} -body {
.l configure -background non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test listbox-23.8 {configuration options} -body {
.l itemconfigure 0 -bg #ff0000
list [lindex [.l itemconfigure 0 -bg] 4] [.l itemcget 0 -bg]
} -cleanup {
.l configure -bg #ffffff
} -result {{#ff0000} #ff0000}
test listbox-23.9 {configuration options} -body {
.l configure -bg non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test listbox-23.10 {configuration options} -body {
.l itemconfigure 0 -fg #110022
list [lindex [.l itemconfigure 0 -fg] 4] [.l itemcget 0 -fg]
} -cleanup {
.l configure -fg #000000
} -result {{#110022} #110022}
test listbox-23.11 {configuration options} -body {
.l configure -fg bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-23.12 {configuration options} -body {
.l itemconfigure 0 -foreground #110022
list [lindex [.l itemconfigure 0 -foreground] 4] [.l itemcget 0 -foreground]
} -cleanup {
.l configure -foreground #000000
} -result {{#110022} #110022}
test listbox-23.13 {configuration options} -body {
.l configure -foreground bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-23.14 {configuration options} -body {
.l itemconfigure 0 -selectbackground #110022
list [lindex [.l itemconfigure 0 -selectbackground] 4] [.l itemcget 0 -selectbackground]
} -cleanup {
.l configure -selectbackground #c3c3c3
} -result {{#110022} #110022}
test listbox-23.15 {configuration options} -body {
.l configure -selectbackground bogus
} -returnCodes error -result {unknown color name "bogus"}
test listbox-23.16 {configuration options} -body {
.l itemconfigure 0 -selectforeground #654321
list [lindex [.l itemconfigure 0 -selectforeground] 4] [.l itemcget 0 -selectforeground]
} -cleanup {
.l configure -selectforeground #000000
} -result {{#654321} #654321}
test listbox-23.17 {configuration options} -body {
.l configure -selectforeground bogus
} -returnCodes error -result {unknown color name "bogus"}
# ListboxWidgetObjCmd, itemcget
test listbox-24.1 {itemcget} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c d
.l itemcget 0 -fg
} -cleanup {
destroy .l
} -result {}
test listbox-24.2 {itemcget} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c d
.l itemconfigure 0 -fg red
.l itemcget 0 -fg
} -cleanup {
destroy .l
} -result red
test listbox-24.3 {itemcget} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c d
catch {.l itemcget 0} result
set result
} -cleanup {
destroy .l
} -result {wrong # args: should be ".l itemcget index option"}
test listbox-24.4 {itemcget, itemcg shortcut} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c d
catch {.l itemcg 0} result
set result
} -cleanup {
destroy .l
} -result {wrong # args: should be ".l itemcget index option"}
# General item configuration issues
test listbox-25.1 {listbox item configurations and widget based deletions} -setup {
destroy .l
} -body {
listbox .l
.l insert end a
.l itemconfigure 0 -fg red
.l delete 0 end
.l insert end a
.l itemcget 0 -fg
} -cleanup {
destroy .l
} -result {}
test listbox-25.2 {listbox item configurations and widget based inserts} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c
.l itemconfigure 0 -fg red
.l insert 0 1 2 3 4
list [.l itemcget 0 -fg] [.l itemcget 4 -fg]
} -cleanup {
destroy .l
} -result {{} red}
# state issues
test listbox-26.1 {listbox disabled state disallows inserts} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c
.l configure -state disabled
.l insert end d e f
.l get 0 end
} -cleanup {
destroy .l
} -result [list a b c]
test listbox-26.2 {listbox disabled state disallows deletions} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c
.l configure -state disabled
.l delete 0 end
.l get 0 end
} -cleanup {
destroy .l
} -result [list a b c]
test listbox-26.3 {listbox disabled state disallows selection modification} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c
.l selection set 0
.l selection set 2
.l configure -state disabled
.l selection clear 0 end
.l selection set 1
.l curselection
} -cleanup {
destroy .l
} -result [list 0 2]
test listbox-26.4 {listbox disabled state disallows anchor modification} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c
.l selection anchor 0
.l configure -state disabled
.l selection anchor 2
.l index anchor
} -cleanup {
destroy .l
} -result 0
test listbox-26.5 {listbox disabled state disallows active modification} -setup {
destroy .l
} -body {
listbox .l
.l insert end a b c
.l activate 0
.l configure -state disabled
.l activate 2
.l index active
} -cleanup {
destroy .l
} -result 0
test listbox-27.1 {widget deletion while active} -setup {
destroy .l
} -body {
pack [listbox .l]
update
.l configure -cursor xterm -xscrollcommand { destroy .l }
update idle
winfo exists .l
} -cleanup {
destroy .l
} -result 0
test listbox-28.1 {listbox -activestyle} -setup {
destroy .l
} -body {
listbox .l -activ non
.l cget -activestyle
} -cleanup {
destroy .l
} -result none
test listbox-28.2 {listbox -activestyle} -constraints {
nonwin
} -setup {
destroy .l
} -body {
listbox .l
.l cget -activestyle
} -cleanup {
destroy .l
} -result dotbox
test listbox-28.3 {listbox -activestyle} -constraints {
win
} -setup {
destroy .l
} -body {
listbox .l
.l cget -activestyle
} -cleanup {
destroy .l
} -result underline
test listbox-28.4 {listbox -activestyle} -setup {
destroy .l
} -body {
listbox .l -activestyle und
.l cget -activestyle
} -cleanup {
destroy .l
} -result underline
test listbox-29.1 {listbox selection behavior, -state disabled} -setup {
destroy .l
} -body {
listbox .l
.l insert end 1 2 3
.l selection set 2
set out [.l selection includes 2]
.l configure -state disabled
# still return 1 when disabled, because 'selection get' will work,
# but selection cannot be changed (new behavior since 8.4)
.l selection set 3
lappend out [.l selection includes 2] [.l curselection]
} -cleanup {
destroy .l
} -result {1 1 2}
test listbox-30.1 {Bug 3607326} -setup {
destroy .l
unset -nocomplain a
} -body {
array set a {}
listbox .l -listvariable a
} -cleanup {
destroy .l
unset -nocomplain a
} -result * -match glob -returnCodes error
test listbox-31.1 {<<ListboxSelect>> event} -setup {
destroy .l
unset -nocomplain res
} -body {
pack [listbox .l -state normal]
update
bind .l <<ListboxSelect>> {lappend res [%W curselection]}
.l insert end a b c
focus -force .l
event generate .l <1> -x 5 -y 5 ; # <<ListboxSelect>> fires
.l configure -state disabled
focus -force .l
event generate .l <Control-Home> ; # <<ListboxSelect>> does NOT fire
.l configure -state normal
focus -force .l
event generate .l <Control-End> ; # <<ListboxSelect>> fires
.l selection clear 0 end ; # <<ListboxSelect>> does NOT fire
.l selection set 1 1 ; # <<ListboxSelect>> does NOT fire
lappend res [.l curselection]
} -cleanup {
destroy .l
unset -nocomplain res
} -result {0 2 1}
test listbox-31.2 {<<ListboxSelect>> event on lost selection} -setup {
destroy .l
} -body {
pack [listbox .l -exportselection true]
update
bind .l <<ListboxSelect>> {lappend res [list [selection own] [%W curselection]]}
.l insert end a b c
focus -force .l
event generate .l <1> -x 5 -y 5 ; # <<ListboxSelect>> fires
selection clear ; # <<ListboxSelect>> fires again
set res
} -cleanup {
destroy .l
} -result {{.l 0} {{} {}}}
resetGridInfo
deleteWindows
option clear
# cleanup
cleanupTests
return
|