shortcuteditor.py
103 KB
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
# --------------------------------------------------------------------------------- #
# SHORTCUTEDITOR wxPython IMPLEMENTATION
# Inspired By the GIMP Shortcut Editor.
#
# Andrea Gavana, @ 05 March 2012
# Latest Revision: 21 Jun 2012, 20.00 GMT
#
#
# TODO List
#
# 1. Check the various IDs in the KEYMAP dictionary to try and understand if all
# the possible shortcut combinations can be handled.
#
# 2. Verify that the current shortcut handling is working as advertised.
#
#
# For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
# Write To Me At:
#
# andrea.gavana@maerskoil.com
# andrea.gavana@gmail.com
#
# Or, Obviously, To The wxPython Mailing List!!!
#
#
# End Of Comments
# --------------------------------------------------------------------------------- #
"""
:class:`ShortcutEditor` is a widget that allows the user to customize and change keyboard
shortcuts via a dialog. It can be used to edit :class:`MenuItem` shortcuts or accelerators
defined in a :class:`AcceleratorTable`.
.. note::
:class:`ShortcutEditor` **requires** the minimum AGW version 0.9.3 or the current
SVN, for the various enhancements made to the :class:`~lib.agw.hypertreelist.HyperTreeList`
and :class:`~lib.agw.genericmessagedialog.GenericMessageDialog`
widgets.
Description
===========
:class:`ShortcutEditor` is a widget that allows the user to customize and change keyboard
shortcuts via a dialog. It can be used to edit :class:`MenuItem` shortcuts or accelerators
defined in a :class:`AcceleratorTable`.
The interface itself is very much inpired by the GIMP shortcut editor:
http://graphicssoft.about.com/od/gimptutorials/tp/keyboard-shortcut-editor.htm
There are very few minor UI differences between :class:`ShortcutEditor` and the GIMP one,
although the behaviour should be pretty much equivalent.
Various features:
* Shortcuts are listed in a tree-like structure, pretty much reflecting a menu
hierarchy (as most of the time :class:`ShortcutEditor` is used to edit :class:`MenuItem`
shortcuts);
* Accelerators defined via :class:`AcceleratorTable` are handled in a similar way;
* Support for I18N;
* Ability to restore default shortcuts/accelerators via a UI button;
* Possibility to send back the new/updated shortcuts to the original :class:`MenuBar` or
the original :class:`AcceleratorTable`;
* Filters on the shortcuts label (case-insensitive);
* Basic help window with instructions (customizable via meth:`~ShortcutEditor.SetHTMLHelpFile`), via
the ``Help`` button.
And a lot more. Check the demo for an almost complete review of the functionalities.
UI Interactions
===============
1. In the :class:`ShortcutEditor` dialog you can open sub-sections by clicking the small box
with a + sign in it next to each section name. In the screen grab, you can see I've
opened the *Options* sub-section as I'm going to add a keyboard shortcut to the
*OptionsItem 1* item.
.. figure:: _static/images/sphinxdocs/ShortcutEditor_1_thumb.png
:alt: Open Subsections
:figclass: floatcenter
:target: _static/images/sphinxdocs/ShortcutEditor_1.png
**Figure 1**
2. Now you need to scroll to the tool or command that you want to edit and click on it
to select it. When selected, the text for that tool in the *Shortcut* column changes
to read 'New accelerator...' and you can press the key or combination of keys you
want to assign as a shortcut.
.. figure:: _static/images/sphinxdocs/ShortcutEditor_2_thumb.png
:alt: Assign Shortcut
:figclass: floatcenter
:target: _static/images/sphinxdocs/ShortcutEditor_2.png
**Figure 2**
3. I've changed the *OptionsItem 1*'s keyboard shortcut to ``Shift+Ctrl+F`` by pressing
the ``Shift``, ``Ctrl`` and ``F`` keys simultaneously. If you want to remove a keyboard
shortcut from any tool or command, just click on it to select it and then when the
'New accelerator...' text displays, press the backspace key and the text will change
to 'Disabled'.
Once you're happy that your keyboard shortcuts are set up as you wish, simply click
the ``OK`` button.
.. figure:: _static/images/sphinxdocs/ShortcutEditor_3_thumb.png
:alt: Remove/Save Shortcuts
:figclass: floatcenter
:target: _static/images/sphinxdocs/ShortcutEditor_3.png
**Figure 3**
4. If you thought my choice of ``Shift+Ctrl+F`` was an odd selection, I chose it because
it was a keyboard combination that hadn't already been assigned to any tool or command.
If you try to assign a keyboard shortcut that is already in use, an alert will open
telling you what the shortcut is currently being used for. If you want to keep the
original shortcut, just click the ``Cancel`` button, otherwise click ``Reassign shortcut``
to make the shortcut apply to your new selection.
.. figure:: _static/images/sphinxdocs/ShortcutEditor_4_thumb.png
:alt: Reassigning Shortcuts
:figclass: floatcenter
:target: _static/images/sphinxdocs/ShortcutEditor_4.png
**Figure 4**
Base Functionalities
====================
There are basically three ways to populate the :class:`ShortcutEditor` dialog, depending on
your needs. These approaches can be combined if needed.
1) Use the meth:`~ShortcutEditor.FromMenuBar` method: if you need to give your user the ability to edit
the various :class:`MenuItem` shortcuts in your application, you can create :class:`ShortcutEditor`
in this way::
# Build your wx.MenuBar first!!!
# "self" is an instance of wx.TopLevelWindow
dlg = ShortcutEditor(self)
dlg.FromMenuBar(self)
# Here the user will make all the various modifications
# to the shortcuts
if dlg.ShowModal() == wx.ID_OK:
# Changes accepted, send back the new shortcuts to
# the TLW wx.MenuBar
dlg.ToMenuBar(self)
dlg.Destroy()
2) Use the meth:`~ShortcutEditor.FromAcceleratorTable` method: if you need to give your user the ability to edit
the various accelerators you set via :class:`AcceleratorTable` in your application, you can
create :class:`ShortcutEditor` in this way::
# Build your wx.AcceleratorTable first!!!
# "accelTable" is a list of tuples (4 elements per tuple)
accelTable = []
# Every tuple is defined in this way:
for label, flags, keyCode, cmdID in my_accelerators:
# label: the string used to show the accelerator into the ShortcutEditor dialog
# flags: a bitmask of wx.ACCEL_ALT, wx.ACCEL_SHIFT, wx.ACCEL_CTRL, wx.ACCEL_CMD,
# or wx.ACCEL_NORMAL used to specify which modifier keys are held down
# keyCode: the keycode to be detected (i.e., ord('b'), wx.WXK_F10, etc...)
# cmdID: the menu or control command ID to use for the accelerator event.
accel_tuple = (label, flags, keyCode, cmdID)
accelTable.append(accel_tuple)
dlg = ShortcutEditor(self)
dlg.FromAcceleratorTable(accelTable)
# Here the user will make all the various modifications
# to the shortcuts
if dlg.ShowModal() == wx.ID_OK:
# Changes accepted, send back the new shortcuts to
# the window with the wx.AcceleratorTable:
dlg.ToAcceleratorTable(self)
dlg.Destroy()
3) Build your own hierarchy of shortcuts using meth:`~ShortcutEditor.GetShortcutManager`::
dlg = ShortcutEditor(self)
manager = dlg.GetShortcutManager()
for label, accelerator, bitmap, help, cmdID in my_list:
shortcut = Shortcut(label, accelerator, bitmap, help, accelId=cmdID)
manager.AppendItem(shortcut)
dlg.ShowModal()
dlg.Destroy()
Usage
=====
Usage example::
import wx
import wx.lib.agw.shortcuteditor as SE
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "ShortcutEditor Demo")
bar = wx.MenuBar()
menu = wx.Menu()
menu.Append(101, "&Mercury", "This the text in the Statusbar")
menu.Append(102, "&Venus", "")
menu.Append(103, "&Earth", "You may select Earth too")
menu.AppendSeparator()
menu.Append(104, "&Close", "Close this frame")
bar.Append(menu, 'File')
self.SetMenuBar(bar)
dlg = SE.ShortcutEditor(self)
dlg.FromMenuBar(self)
if dlg.ShowModal() == wx.ID_OK:
# Changes accepted, send back the new shortcuts to the TLW wx.MenuBar
dlg.ToMenuBar(self)
dlg.Destroy()
# our normal wxApp-derived class, as usual
app = wx.App(0)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
Window Styles
=============
`No particular window styles are available for this class.`
Events Processing
=================
This class processes the following events:
========================= ==================================================
Event Name Description
========================= ==================================================
``EVT_SHORTCUT_CHANGING`` Event emitted when the user is about to change a shortcut.
``EVT_SHORTCUT_CHANGED`` Event emitted when the user has changed a shortcut.
========================= ==================================================
Supported Platforms
===================
:class:`ShortcutEditor` has been tested on the following platforms:
* Windows (Windows Vista/7);
License And Version
===================
:class:`ShortcutEditor` is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 21 Jun 2012, 20.00 GMT
Version 0.1
.. versionadded:: 0.9.3
"""
# Version Info
__version__ = "0.1"
import wx
import os
import sys
import wx.html
import wx.lib.buttons as buttons
from wx.lib.embeddedimage import PyEmbeddedImage
from wx.lib.mixins import treemixin
# AGW stuff
import hypertreelist as HTL
import genericmessagedialog as GMD
# add support for I18N
_ = wx.GetTranslation
try:
dirName = os.path.dirname(os.path.abspath(__file__))
except:
dirName = os.path.dirname(os.path.abspath(sys.argv[0]))
# ----------------------------------------------------------------------------
# Constants
# ----------------------------------------------------------------------------
DATA_DIR = os.path.join(dirName, 'data')
""" The folder where the default HTML help for :class:`ShortcutEditor` lives. """
# These commented out things need to be taken into account somehow, but I
# have no idea how to treat them and even if they could be valid accelerators
KEYMAP = {
wx.WXK_BACK : 'Back',
wx.WXK_TAB : 'Tab',
wx.WXK_RETURN : 'Enter',
wx.WXK_ESCAPE : 'Esc',
wx.WXK_SPACE : 'Space',
wx.WXK_DELETE : 'Delete',
wx.WXK_START : 'Start',
wx.WXK_CANCEL : 'Cancel',
wx.WXK_CLEAR : 'Clear',
wx.WXK_MENU : 'Menu',
wx.WXK_PAUSE : 'Pause',
wx.WXK_CAPITAL : 'Capital',
wx.WXK_END : 'End',
wx.WXK_HOME : 'Home',
wx.WXK_LEFT : 'Left',
wx.WXK_UP : 'Up',
wx.WXK_RIGHT : 'Right',
wx.WXK_DOWN : 'Down',
wx.WXK_SELECT : 'Select',
wx.WXK_PRINT : 'Print',
wx.WXK_EXECUTE : 'Execute',
wx.WXK_SNAPSHOT : 'Snapshot',
wx.WXK_INSERT : 'Insert',
wx.WXK_HELP : 'Help',
# wx.WXK_NUMPAD0 : 'WXK_NUMPAD0',
# wx.WXK_NUMPAD1 : 'WXK_NUMPAD1',
# wx.WXK_NUMPAD2 : 'WXK_NUMPAD2',
# wx.WXK_NUMPAD3 : 'WXK_NUMPAD3',
# wx.WXK_NUMPAD4 : 'WXK_NUMPAD4',
# wx.WXK_NUMPAD5 : 'WXK_NUMPAD5',
# wx.WXK_NUMPAD6 : 'WXK_NUMPAD6',
# wx.WXK_NUMPAD7 : 'WXK_NUMPAD7',
# wx.WXK_NUMPAD8 : 'WXK_NUMPAD8',
# wx.WXK_NUMPAD9 : 'WXK_NUMPAD9',
wx.WXK_MULTIPLY : '*',
wx.WXK_ADD : '+',
# wx.WXK_SEPARATOR : 'WXK_SEPARATOR',
wx.WXK_SUBTRACT : '-',
wx.WXK_DECIMAL : '.',
wx.WXK_DIVIDE : '/',
wx.WXK_F1 : 'F1',
wx.WXK_F2 : 'F2',
wx.WXK_F3 : 'F3',
wx.WXK_F4 : 'F4',
wx.WXK_F5 : 'F5',
wx.WXK_F6 : 'F6',
wx.WXK_F7 : 'F7',
wx.WXK_F8 : 'F8',
wx.WXK_F9 : 'F9',
wx.WXK_F10 : 'F10',
wx.WXK_F11 : 'F11',
wx.WXK_F12 : 'F12',
wx.WXK_F13 : 'F13',
wx.WXK_F14 : 'F14',
wx.WXK_F15 : 'F15',
wx.WXK_F16 : 'F16',
wx.WXK_F17 : 'F17',
wx.WXK_F18 : 'F18',
wx.WXK_F19 : 'F19',
wx.WXK_F20 : 'F20',
wx.WXK_F21 : 'F21',
wx.WXK_F22 : 'F22',
wx.WXK_F23 : 'F23',
wx.WXK_F24 : 'F24',
wx.WXK_NUMLOCK : 'NumLock',
wx.WXK_SCROLL : 'Scroll',
wx.WXK_PAGEUP : 'PgUp',
wx.WXK_PAGEDOWN : 'PgDn',
# wx.WXK_NUMPAD_SPACE : 'WXK_NUMPAD_SPACE',
# wx.WXK_NUMPAD_TAB : 'WXK_NUMPAD_TAB',
# wx.WXK_NUMPAD_ENTER : 'WXK_NUMPAD_ENTER',
# wx.WXK_NUMPAD_F1 : 'WXK_NUMPAD_F1',
# wx.WXK_NUMPAD_F2 : 'WXK_NUMPAD_F2',
# wx.WXK_NUMPAD_F3 : 'WXK_NUMPAD_F3',
# wx.WXK_NUMPAD_F4 : 'WXK_NUMPAD_F4',
# wx.WXK_NUMPAD_HOME : 'WXK_NUMPAD_HOME',
# wx.WXK_NUMPAD_LEFT : 'WXK_NUMPAD_LEFT',
# wx.WXK_NUMPAD_UP : 'WXK_NUMPAD_UP',
# wx.WXK_NUMPAD_RIGHT : 'WXK_NUMPAD_RIGHT',
# wx.WXK_NUMPAD_DOWN : 'WXK_NUMPAD_DOWN',
# wx.WXK_NUMPAD_PRIOR : 'WXK_NUMPAD_PRIOR',
# wx.WXK_NUMPAD_PAGEUP : 'WXK_NUMPAD_PAGEUP',
# wx.WXK_NUMPAD_NEXT : 'WXK_NUMPAD_NEXT',
# wx.WXK_NUMPAD_PAGEDOWN : 'WXK_NUMPAD_PAGEDOWN',
# wx.WXK_NUMPAD_END : 'WXK_NUMPAD_END',
# wx.WXK_NUMPAD_BEGIN : 'WXK_NUMPAD_BEGIN',
# wx.WXK_NUMPAD_INSERT : 'WXK_NUMPAD_INSERT',
# wx.WXK_NUMPAD_DELETE : 'WXK_NUMPAD_DELETE',
# wx.WXK_NUMPAD_EQUAL : 'WXK_NUMPAD_EQUAL',
# wx.WXK_NUMPAD_MULTIPLY : 'WXK_NUMPAD_MULTIPLY',
# wx.WXK_NUMPAD_ADD : 'WXK_NUMPAD_ADD',
# wx.WXK_NUMPAD_SEPARATOR : 'WXK_NUMPAD_SEPARATOR',
# wx.WXK_NUMPAD_SUBTRACT : 'WXK_NUMPAD_SUBTRACT',
# wx.WXK_NUMPAD_DECIMAL : 'WXK_NUMPAD_DECIMAL',
# wx.WXK_NUMPAD_DIVIDE : 'WXK_NUMPAD_DIVIDE',
#
# wx.WXK_WINDOWS_LEFT : 'WXK_WINDOWS_LEFT',
# wx.WXK_WINDOWS_RIGHT : 'WXK_WINDOWS_RIGHT',
# wx.WXK_WINDOWS_MENU : 'WXK_WINDOWS_MENU',
# wx.WXK_SPECIAL1 : 'WXK_SPECIAL1',
# wx.WXK_SPECIAL2 : 'WXK_SPECIAL2',
# wx.WXK_SPECIAL3 : 'WXK_SPECIAL3',
# wx.WXK_SPECIAL4 : 'WXK_SPECIAL4',
# wx.WXK_SPECIAL5 : 'WXK_SPECIAL5',
# wx.WXK_SPECIAL6 : 'WXK_SPECIAL6',
# wx.WXK_SPECIAL7 : 'WXK_SPECIAL7',
# wx.WXK_SPECIAL8 : 'WXK_SPECIAL8',
# wx.WXK_SPECIAL9 : 'WXK_SPECIAL9',
# wx.WXK_SPECIAL10 : 'WXK_SPECIAL10',
# wx.WXK_SPECIAL11 : 'WXK_SPECIAL11',
# wx.WXK_SPECIAL12 : 'WXK_SPECIAL12',
# wx.WXK_SPECIAL13 : 'WXK_SPECIAL13',
# wx.WXK_SPECIAL14 : 'WXK_SPECIAL14',
# wx.WXK_SPECIAL15 : 'WXK_SPECIAL15',
# wx.WXK_SPECIAL16 : 'WXK_SPECIAL16',
# wx.WXK_SPECIAL17 : 'WXK_SPECIAL17',
# wx.WXK_SPECIAL18 : 'WXK_SPECIAL18',
# wx.WXK_SPECIAL19 : 'WXK_SPECIAL19',
# wx.WXK_SPECIAL2 : 'WXK_SPECIAL2',
}
# Define a dictionary to hold the correspondence between wx.ACCEL_* and
# human-readable names
ACCELERATORS = {wx.ACCEL_ALT : 'Alt',
wx.ACCEL_CTRL : 'Ctrl',
wx.ACCEL_NORMAL: '',
wx.ACCEL_SHIFT : 'Shift'}
# Define a dictionary to hold the correspondence between wx.MOD_* and
# human-readable names (platform dependent)
if wx.Platform == '__WXMAC__':
MODIFIERS = [(wx.MOD_CONTROL, 'Cmd'), (wx.MOD_ALT, 'Alt'), (wx.MOD_SHIFT, 'Shift'), (wx.MOD_META, 'Meta')]
else:
MODIFIERS = [(wx.MOD_CONTROL, 'Ctrl'), (wx.MOD_ALT, 'Alt'), (wx.MOD_SHIFT, 'Shift'), (wx.MOD_WIN, 'Win')]
# Define a couple of standard, default accelerators
NEW_ACCEL_STRING = _('New accelerator...')
""" The string to display when the user wants to enter a new accelerator (by default is `New accelerator...`). """
DISABLED_STRING = _('Disabled')
""" The string to display when an accelerator is disabled (by default is `Disabled`). """
# Events handled by ShortcutEditor
wxEVT_SHORTCUT_CHANGING = wx.NewEventType()
wxEVT_SHORTCUT_CHANGED = wx.NewEventType()
EVT_SHORTCUT_CHANGING = wx.PyEventBinder(wxEVT_SHORTCUT_CHANGING, 1)
""" Event emitted when the user is about to change a shortcut. """
EVT_SHORTCUT_CHANGED = wx.PyEventBinder(wxEVT_SHORTCUT_CHANGED, 1)
""" Event emitted when the user has changed a shortcut. """
# Standard images for all the buttons we use in the dialog
#----------------------------------------------------------------------
_cancel = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0"
"RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAQQSURBVHjaAEEAvv8BXTIyAAL9"
"/UEy6Oip+fn5BqAAAHX1/f2bBP7+ACMDAwA4BQUAB/z8AAH6+hQhCQm7FAsLKpPm5qfh/f1g"
"4QAAAAIAQQC+/wMtGBhBLufnr1w5ORI1JycI+traR9QBAev4/v7NFQICABsDAwAB/PwUFwAA"
"vDdJSTA0X18DIujoL9Lm5iLZAACyAgBBAL7/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X/6/HzPwc6xBnkbw6gjWpAF6kDaUNGxoxFSko/7lpY/E/n5//ByMBQAlID"
"EEAMqmJiDNJAWxX4+dsluLh2A8XcGKAAZoA+MEdqAvn6jIwx+iwse5kZGAphagACDAAeLHBa"
"S9SUbwAAAABJRU5ErkJggg==")
#----------------------------------------------------------------------
_clear = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAA"
"B3RJTUUH1wYeFCULmGdR+AAAAnpJREFUOI2V0ktIVFEcBvDv3jveufO4jk46ZVlGNUGRLTIp"
"K8OCoAdBIM2ioo2LCKFsI7QJCQoiiJ60nCDBTbUpsJSh0cxw42DImA2j1vhImXFmvPM493VO"
"izDS6WFn/X0/+H8cDv/xHpyzXuYs/FVdVT2iVbre/CTXxq+0fP+M9ZLNId/YVd+4+tTZFo5o"
"rBUAVgQ8PI9VsOBmTf1JR3+wE18igyCcHAUAy0oAysSLFeuqBJFMoW7nerwZ+JzLGFLLP4FP"
"70r7KOOeBzqMZpeYl+KxEPqiYlbVhHt3XnwN/PUEf5tfMg3Lfrmk+tYhn3VNWXUeUYXXFogQ"
"GhNi1xZzwp+AxiN7H01EjtaoxCt4KmvhLMvA6priqzaTjrxFDQSDYADALS+Ov4WkWzxPDWY7"
"np4/IY0Ob+RHQgrc5QnsafgIQx+CrqH1WJNyuwCI9DrLqeAI2GXvlrVVp22MmdDyMYyPJvDM"
"TxEJ21HXMNBeXjvU5PNBWwJEu0tdpk18L5ft9pa4a0ShSIapzUGZHwEvZKCTafR2ZzXOmfP4"
"LiTTiz0eAGL9lTbDLnY53dWbZNd2MZuegKnHoeYnkVuIQVdnoKszcDhTBVvxAJCj2iuH7N3h"
"kLfapsdewlFcAY1MITU7AmokoaSmAVDoKoDkbwBK1cOi6LZPjLbD6fJCV2cQDfeAZGdBzSSS"
"CQrGAMPgeJBkvgAAuIZvk0HoGiBKEsKhTj0VT4IaC+AFA/E5DprKATzSvrYf4y0Bth1M9RDT"
"soHSosfhwdcsq5AiajBqmgbyhEdGARJxRnmOdS/foOAfAECXv9hrmuwuIeyApqL4Z5jn9vmu"
"KB9+zX4H1k8cy/juDWsAAAAASUVORK5CYII=")
#----------------------------------------------------------------------
_default = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlw"
"SFlzAAAK8AAACvABQqw0mAAAACV0RVh0U29mdHdhcmUATWFjcm9tZWRpYSBGaXJld29ya3Mg"
"TVggMjAwNId2rM8AAAAWdEVYdENyZWF0aW9uIFRpbWUAMDIvMTEvMDeS+i0/AAACvklEQVR4"
"nKWSXUjVdxjHP7/f/+W8qdPqj5rRPAsryDM2FIRBjEQotjuHsV2NCIPqoqju6iqnuYu9ZKtw"
"N7mKujGqDXQ3o9UQEsl8mYl1OGp5lDRt5+h5+Z/j///rIgVfops98MDDw/N8+D4vQinF/zG5"
"NtHU2LDn8qWL1StS1q329khj43dPZ1/P578X8Mfvdw/W1Oy9Mzo21l5bW1vjy/XKCy0tZ4LB"
"YHBudq6s/uC3x9YCdADchIUMzHR13du/9cOyvEgkAspp7uvpMzs7/wz9dP5nno2GldBFIWAA"
"2dUKhMoODju1wZ11u65fu0o0GnW2lIbse38/CMXiMR739rF722fcbrr5iZ1JhFYqEG+XOCR+"
"aStr/W/erNfFDAG/oYpzXtrXrh7x9j4b52T5VxyvPMHAZA+bzlZt3Fxgza0egV0qmcy+TsRB"
"ahYTzxFf11327jtXxmSsku0l20hfuE9qmnSgwFp1tqUl9oFAahKkAE1X2Il5csxpthdPwNg/"
"QAqh68IF8Q5AaY6hu7arKaQXhAZCGiB1cAS4BkJqCEN6AmQ3rb8CnhJpZ/qHHjrkF9r4/Dmg"
"ZcFYAkhBMp3GNfMepTHC5nqAb2TqZWJrMu4wM5lkYTHKSO4gRVUpKC1CMwMMd00ytUNMV4H7"
"DgWQXURJAZqhkcnAq5EIsdlpjKJxuiMbyA7v58nGoY/vHD5QveWDwti55ubHgLv8SNLjdV3d"
"cFhcANcRxFIJpN+DtpDgxWiaT/MsOu9fKentCv+lS42Ojo6m/oGB08uv/NGhA/qjyqr5b8pD"
"dnd+QZxcv4lKJzGERkxPcjLRwr/OKHbaxvR4lGVZDwFQSi15dDk2w2MTX6Qe/Ppj+PsvpzIN"
"5W5zdZ5Cw/X5fcmKiorrbW2/7VjuWwFY73GlyrP9N9pbT9WNf16z94emxoaja2veALFzTWMO"
"z/GRAAAAAElFTkSuQmCC")
#----------------------------------------------------------------------
_help = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAC+ElEQVR4nGWTP2xbVRjFf9+9"
"9/01TgwJCQkMbkMKqCkEKGoXBpiQEqkpZUL8y8BeRqYwMMBQRMWMGtQgJCSKYWCohARIVCCo"
"MJUgLbSipVERTuzYcexn+713L4OlirafdLZzznC+c4TbbnZxrSTIEkoeQ9S8iICob0WkevHM"
"C5Xb+XKLeOH08WIxXnloZqoUhSFRFDHIcmr1XerNDts7navWuTfWPz1SucNgduH0qfm58mt7"
"y/ezfq1LrZmR2SHFaAg9QTtLo1WnnybLv3+yuHrTYHZh7a1DT8ysFEfH+eVyh73TEa8vTvL0"
"o0WsdXzz6w6nzm5x5cYALdDtNMgG3aO/ffxcRWYX18pTE6W/Dj7+CN9daDM17lN5+2GsteS5"
"w1qLc44b9ZSXTlxHRHDOkrRqTWvzPXp837GVw0/OHl7fyOiljt2eJQ4U9VbGiTM1HLBn0iP2"
"hR8v92n1QGmNaB3m6eCS8QNvSZmI7XYXRECED76skTshs6C18OyBGOccm7uOTjrMLNQRottH"
"zOhIoVxrpsM0BPqpo9vJEa15YMLnzWNjWGs590efRg/8yABQUJB0dclYB71BjnWwvZORI3i+"
"RnuKd16ZIA6EK/9mnPy6QxB7KDV8XDFw1BsGM0hzBMfmdooTwfgKZRQLB+9iZtJgrePD7xNS"
"ZQgChdIKgJGCRZRGdZJBpd1OsM4hSlB6iKl7DM45nHNc2nQEoSGIPMLYY2TEIwxAtKkaRH3R"
"au8uFcNRulZQaojKzwn7pn22EjC+xgs0fuhhfE15DP5cbyFKf6Qufvb8atJPqpHOMQKIIEo4"
"+lTMoRmfhTmfuWmD9jReqJm+10ORs/FPv3L+/QNVBeBwy4O01QzE3uz2hesp3QFs7MDfTYdR"
"cN+oUPIyzv3QqIrSy7dsYf+LX82jzOe5GS3rsEgcGeKCR6FouLvkMVYybDV6XNtIqoNMnvnp"
"3Qebd6xx7uWzJZQ6Ltp71XhBOS7EhJEhzS27SV4VbU6ef2//6v81/wH6bjI8fK9HXAAAAABJ"
"RU5ErkJggg==")
#----------------------------------------------------------------------
_info = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAFz"
"UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA"
"AAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAN1gAADdYBkG95nAAAEURJREFUeNrtmmlsXNd1"
"x//n3Hvfm53kcEiKpERSmy3LdmwlSrwVcZM4qdE6CVB0M4p8CBL0S9ECTb61/dD0cxq3KPKp"
"SIK2aZAWbeo2cd0kcJp4ixfZlmxHu0RJXGaG23D2mffevacf3oxEs/JObWgecPguhrPc87tn"
"uefcB/zy+uX1//qiq/2DrDT56cFsZmhyfPLme3ea7MB+ERkDABLUIpazpfOHTzUWTi+210or"
"UdAOIHLjA/DSg35h6rZbd33k0w8PbtvzK6lsfkcilR0wmn3FUADBibjIIeoGnVanWV9uri6c"
"WJp95dHZFx/7YW3lQlFsJDccAGV8tW3fPQf3P/CFL+VHpu/PZtKFoTSCiSETDWWMJH0FrQgE"
"wDkgsA7NjqXyesDlmvNrLRvVKiuzpZPPf/fYk9/5u/XFU0VAbgwA2cLU8J2//odfnth3z+cH"
"c6mRnS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sO4L2JSNRs1H8RheGqE8k3Wx1Vqze61Wp1YalU/Nfl0uKjztn1"
"3gqHmyTaIO4tRDaMr0oMuKz/b84MG+4KgNLG5I3xCgAoDINKFIbVDWZrNykcbri/le+7qxED"
"NrvCm2aCy7jFxjtdxqJk02raNxm/VQa4Klngci6xWXG6zHizW2yey2b/lU1mLW9j/ld1H/BO"
"4sObKY93AUDeJPi9o5W+2gDe6rc2mzzeBgAuE9W37PpfnmQMHSrQKjcAAAAASUVORK5CYII=")
#----------------------------------------------------------------------
_ok = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAANkE3LLaAgAAAjpJ"
"REFUeJy90k1IkwEcx/Hvs2evMt1KJ741Wy0zexMy0US6WHSKgii8pAUZKUEFubSgkjKRQgT1"
"kL0hZNChMpJCi/RQGQll0sBE09wWw5c2c5rbs+fptIgutQ59758//8MP/nNCcsWSm5ajS+8C"
"6qh1con5So+3W3ni6lTiS81XAe1f45QDsXV3JloVT2BC8c57lGZng6LZJVz8+Ub8fpVD0Mri"
"1DVqf8dpZYYLZ6pOOjJi1jDqHyIoS7xwdyMbla1qANNO7fHDx0rrZPV3WufbpOl26iM4/Yju"
"XEXlwdNWvZ3xuY9IssKDT23c6+0l3McjUVfEoe2Vm5vyEwuJ1yVgyRO3jflHfIFBXtvK1dUl"
"jt016ZpM/MFJZiUfTyfbed7/Ct9t6hmiRkzeR2Moddo6G5xBJYZJjEkiMUcoIvtrzo7iLeUp"
"Ohu+oJcpycPA3DPefXiP6zoN0gAOQBYRyLRslAqmtS7coSF8iguNQVFZs0yrtYIGb2iE0eBb"
"3OFBvMMzOBuk2oV+qgAZQFz8zMvwPGkrc3XZQlyIb4KfsNqPUYhFL6pRqWQMOjULEwJ9l3yX"
"Z/uojmAAEQgFhukKLsq2rLyE9XqTiiTtMuwxWaQb7Cw3ZjDjCtBx1tk41SNX/oojBwBCfidd"
"QUlalVtgX5tqsmHVrWCdKZfxL2M0nXrY4nksnQDCf9pL3IZy/f1m917ljXxD6fCeV+zF2ugW"
"B5gLHcbOFtceZVOZ4RagjwZHSrLkUwHE/guOqh90ld9+870vDgAAAABJRU5ErkJggg==")
#----------------------------------------------------------------------
_reassign = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9i"
"ZSBJbWFnZVJlYWR5ccllPAAAAsZJREFUeNqck1lIVGEUx393thaXCm0qtdJrm4FlONGkWESb"
"tthDUA9F9dDyFhTRghI9WJpgPgSBD/UWQRvZrg6CSFk5FuJDD+nYTFCmmaDV2Cz3dr7LBEIv"
"0oE/937nfP/DOed/Pm1XPZMyU2AYNBom5TYNzWYDTXw2KyhRCVjff4iJWDwOv2OU1+5tYDyK"
"qc7qui1u8EACpnJGYtyVsxVQUP8Zs3QzHMH8JfDq0Nl3jIrycyqZKRWhldZiXt1XQSQeo6PP"
"j/9jP6HhgKbKm5+mmx5dx5tbKFVoAged/VXYpe7Zyfu45ruJQ93sDF4kHAXvovOkp6zmec9t"
"q5kdBfvJmeugI3AeK6Mq2SGQBCPhkHW2L97IoXchZqYmwc9oG0vmFZAydSHBbwE2r9LpDF0i"
"OAhdfeAUonuWkH/o3HvVTdNpPPZeH74+Hzdc+ZTNSGbGOG/IdS9jqtPNrVfXZdzwoptg40k2"
"TVnF0bSZTlreDtN8Bk95PV12kXFo6Va+PDtDiy2fw0nTscftPeS4c0hx5fL4dW+ktZL1O+vo"
"joYpDQ4ZWU2KfIUu1ZZNNdt4wmRzNfcPbNzuGh7RCQxA/+gTFmT8ZE9JkUtidx6elJtOvHUH"
"G9hUjf+vWjYjTuuWGs3cXVK8OCtzjOKiAP2SIPgVPofbUb7t3uV5G6o0c+1KGfiQyLhHZIwm"
"ZCy7jHn8QB7x2DSGwm8JfYIvId2a8NzMANlZkOpaRMwYs6Qc+z2AbCJuh8j4SGRU+zhivCcm"
"9QQ/w8sOBpsrA9tUgi0XeSJDnKNn92IkFktLyPg9IaNWWoVfc1GoVjYe5nXLBY7IYHuwZkN+"
"WQ2twktX5OI1IHvFyIDO07YAzWfxqPVYIkhJrP6okD9MfAuSZAVqfGLSrn9diYu29gjPEzJq"
"k32NysZHaXUmseHxKTzC6+I/LFdQONHxR4ABANuzKntCBWfVAAAAAElFTkSuQmCC")
#----------------------------------------------------------------------
_html_back = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0"
"RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAavSURBVHjaYvz//z/DQAKAAGJi"
"GGAAEEAD7gCAAGJBF2Bk7IM6jRGIgTQzkGZG5wMxI0g3mNZh+PGnmoGbhZWBhSkXKPocbth/"
"qBd5mSFqQUJn0lDsAwgg0kMAlmQYGdgYvv3OZPr2e3dgoFqEsqJAIMOvf9YMf4EKQPgPVCE3"
"M8QROABAAJHuAJBH/v1XZnj/c620NO+0hbO9JNbN8WIQFmBnYPgNtPkf1AEgddxMEBoPAAgg"
"FhItZ2T48Tea4d+/1thEXbm6SgsGFQV+hr9//zH8+vUXET6gKAJZzoQUYjgAQAAR7wBGRh6G"
"Tz87BES5sjo67BjTE3XBpv/5/QfVDlBa4QD5nBFiOYEQAAggFuKCnEGN4du3OYamUrbTp7sx"
"mBtLAA3/y/D6838GHrb/DMzMYFv+AS3/y8AODXYiixeAAGIhaPnvvx6MDH+nxyYbKvR02DGI"
"inAy/Ab6evk1RobHn5gYik1/M/z/x8jw/dsfJoavv52Awc4B1McBzz2MUJqViYmBk+UskHUJ"
"2QqAAGIhYHksUP/Mtk5HzrISU3Dovvn6h2H6OWaG/Q8ZGSwlfjMw/vvLwMjMwqCnKcLEyciY"
"x8rNnAdPB8wQg5hZGYGx95vh5vMvt4ECasjWAAQQC07L//6J5uBknD1hoht7eqoeOISvv/7P"
"MOUMM8Ojj4wMXMDQZvz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33mGOw8+MrBwAI1kBDqAEdqCAlKsbEwMrz78YPj8+993"
"dGsAAogFZ6sHFFysLC0fP/x+kZywvff69bd8ZSWGDBaq3Ax9Yf8Zujb/Y3gDCglwqfefYcue"
"h/9un3+5DJgYzgP1sqNURiBbWJhZgc22U+hWAQQQC8HmFwfLnO9//t9trj8y5/z5l0oT+u0Y"
"VGV5GBoCGRhuPPvO8Os3JIVzcQNTHzfragYulk3gWgvdAUzYGwYAAcREVBuQhXE/Aw+H45YN"
"d7a4eW1k2HHoJYOkFB+DvgI3uCL69/8fxKz/QKt+487z2ABAADGR0Bx7xMDPHnrvzoe6oPAt"
"Xxs6zzL8+s/MICTICY4GFAf//E9UawgEAAKIeAdAatofwDhu/vmPwaO16eQF/+gdDFdufWYQ"
"F+EG1xVwK0EO+v4PVI8RbB0BBBB5HRMWpiMM/GxO58687PMK2/qjqPkkMK8D62VmRhZIxcEA"
"KX6//SMYEgABxIjeNySqYwJjgzob//87M/z+V8PIw8L0n4kxGSh6B6NjAmohs0D0oXdMAAKI"
"caA7pwABNOB9Q4AAGnAHAAQYABaU9vBbRzekAAAAAElFTkSuQmCC")
#----------------------------------------------------------------------
_html_forward = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0"
"RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAbWSURBVHjaYvz//z/DQAKAAGJi"
"GGAAEEAD7gCAAGJBF2A0mQVlAPGPfwwMv/9D2HAFDHwMf/9PZfjyR5CBnaWZ4f//kwx/geL/"
"gOqAyoFyDHD+XySxfxCx/78KUewDCCDcIQBKGqxAm9FV/P6nK8zHHuPqrODN/PvvHobvf6qB"
"ouzkhgBAAOGPAmagAziYUcX+/mfiYGJkmNHuyLB6jjePoix/C8P7H7uAIaFLjgMAAgi/A/5D"
"VXCgKvsDDNI/v/8xBLorMezbEMwQm6hnx/jlz25gaBQApdlIcQBAAB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DcqAqYx6xAAAAAElFTkSuQmCC")
#----------------------------------------------------------------------
_html_home = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0"
"RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAmrSURBVHjaYvz//z/DQAKAAGJi"
"GGAAEECMDH5SqCL/oe76ywiWZvjHiJD7xwzEULnf/w0Yfv3tY/jPyMPAzFLOwMq2n+EfNDRB"
"NCMjBP9HNhjqX1CogzAjEwNAAJEXAj+++7Ax/N/QlV/pOLu205Sfk2sVw5fP8eQYBRBALGh8"
"biD2hdL/gBjoZYYrQHwCEmFAH335ksnLJ9QztbCFK9Y9ECwsJSImktZWNf/p40fyDDz8bUDv"
"/SHWAQABxMygzovMlwSG0lZg8IQBg8cfSPsBw+kPMCa2AuXYGT5+7FFX1Gxe2TyT1dfKieHb"
"vy8MP/5+Y9CRV2dws7RjPHP7uuOze3dUGNjYDwCD/zs4CtBiHJXLyAAQQMwMmkDPMv6HYT6g"
"cAKQwQtTAMS7GP79ucjw6eMCD1uvxGV10xn0lTUY3v15xTD9eQPDng8bGFTZ9BhUxVQYAh3d"
"GJ69f6N7+fI5awYW1pMMzMyvGf7jdwBAAAEdwAMRh2B+IE4Fsnjh6v/8+cDw80dMgl+C19yy"
"CQwSgiIMj3/dZZj2vJ7h0pczDK9/vmA4//k4gzSzIoOygAqDn70rw49//+ROXTjt8u/vvwsM"
"LCyP8DkAIICYGbS5kEOAHxh/qUB1vKAUCrQYyPyn3pRcq9ib2sDAwcrGcOHrMYYpz2sZHv+4"
"x8DByMXA9J+N4c2vVwyHP+wGahJg0ODRYXA1t2YQExUTOXDqeMDv71+fAUPjEi4HAAQQM4MW"
"F7IQMAQYgQ5g4mX49plBkE+QYV7xdIZs7wRwbOz+uJph7ssOhs+/PzGw/Odg+PPvL8NvIGb8"
"z8TwDZgWDr7bxfD91zcGI25LBjMdPQZDbR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3/x4"
"DbQHVN//gzSWURzwH5GLGEGpBFQ0/2Ew4DVgEAXlAKDI2y9Az/z79ZGBhf03epsEIIBYwEGH"
"CkC2vPz84zOYEyuXxBAjlwhMDyzACuoPsOBkhFjGBPUJPASB2RQozgEs5FjYWRgmW0wChwQT"
"BxPD5x9fQOkLGAIMv+AOhgKAAGJhwNZyZmJ4dPnZZQYQBid4IASW9sAC4h3Dz3/A4pAJqb0N"
"YzGB1PxnuvniDlDNTwYmYO8JlG4ef3vJcP7+JZCZTxmYGX+j+xYggBgZMhmxlehqLAwss0RY"
"hbWAZvyG5D5GUDXM8u7np/dA2gPo3QeQsp8dFgKijIxMm4RYuFSBJeDPf/8h3Tqg41nf//jx"
"6Off/7lAU46jWwQQQIwD3TsGCKAB7x0DBBgAIYJYB6/AsBcAAAAASUVORK5CYII=")
#----------------------------------------------------------------------
_html_print = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9i"
"ZSBJbWFnZVJlYWR5ccllPAAABwhJREFUeJytl99vVMcVxz9n7tx7d732esHYxmBTfgVRQmg3"
"OBH9IRGgjUBqoBKoapDIQ9NW4qH0oVL/hPahfegD6kvCcyM1b6nUNhJS0kpNSgW0VUQsEpvy"
"yxCDbdZe7957585MH3bXNhRcQBzp7OydOXe+59ecc0eOHfsRK5FzbtOOHdt+v3nzhl7nnHuU"
"3OnTv9oGcPHiRQCq1SqP8yyvvfbGigrkuR09deoHfz94cL9aSa5arS5u/rhUrVbRIrKikIhY"
"Y6wB4odLeMA/MTi0vNG2amUlHk2uzRZIn2oHtbSBRymNiDyUHw7uF5WoVvc8MXi1WkXn+TTe"
"e7wXoqibMCzj/RKg9w8LvV8G3vn/dKRBEAFrDc3mXZwzFItDiLCoWBAED4DbBxRwT50DeulR"
"UEqTZfPkuWX16k2IBEC2LAT3gy4PwdPS//hXqYA0rVGr/Yf5+RuAaSgVtn3slrG/77lzrp+E"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54IP3McZgbatHdGqACCgRlOqU5HbS"
"OXDed8RABFEKHQQoJYyOfo21a4cxxhAEAcZkZFlzRue5ueq9oViM0VqI4wJTU9f48MM/kSQJ"
"pVIXQaDx/gnqfbtKWmtpNpuAY8uWzWzduo0kaaJ1RK3WoNGo39J5nl/JsialUpEkgTiOMCah"
"u7uboaEhXn/9OKtWrSbPzeMrAARBQJIkvPPO75icnMRaQxxrICaOY6anE7Isvarz3Jy/e/eL"
"rLu7EGndenFwcIBXXz1EFBV56aVRjLFY22q9znla1xOP9w7nWm5vtfNWY3IOnPNs2dLLgQMH"
"mZy8yebNGykUQsJQUSgUqdVmybL0ogbOX7586d+HDx8ZrVTKGJPz4ou7KZcHCMOA9euHMcYu"
"AjjnlgG69lyH7eJanlvK5RL79n2LiYnb7N69nYWFBkEQoFTA2NgnV73nL8Ho6Gg2Pz83myTJ"
"Xq3jYpYZtbDQYGxsgtHR7QSBxlqLtXYR0FqHc7Y9dtguKtjhLDP09/dy6dLn7XxYYGpqyn70"
"0V9nzp8/94sgCM5qEUEp9e7Zs3++eP78uRfCMFpnrd51+PB33+jpKRWbzbRtLcu84Bc9sHyu"
"M+99az5Nc6yFkZEB/9Zbb7+rVPMDa93t6em7Y1EUXRKRpU+yMNTjWsfjMzOzRNHA97dv3/xm"
"63j5+9ztPQ8Au4coxOL8zMw8GzYMSRh2f3779s3f9vevIQzDxS9t3Ro91sbcuZOTplHXyy8/"
"f2rjxmENUCoVHpnprXizeESXj8vXCgXNvn17fnzmzJUzN24sjMexJo5b3USnadi2KgAsWsvq"
"ZrNefu+9969Za91K98aV77VLiyLI9euTYaEQfslaN57nIZ129l9hzBKSSHX0vAAAAABJRU5E"
"rkJggg==")
#----------------------------------------------------------------------
_html_reload = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAAK/INwWK6QAAABl0"
"RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAlZ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RMgOUnO0/W91//LpTOr2k9//CKiCCPENBMViZwwxdc7v9Hy46ELUUGAAFERM8IaCAz"
"yywGDpbDy3avncjIyuXKwMrFimEvmQAggIjsmoFsYrrOwMHl/f8vcyWwWaUI9SbFTgAIMAAF"
"XnDxjsZXyQAAAABJRU5ErkJggg==")
#----------------------------------------------------------------------
def FontFromFont(font):
"""
Creates a copy of the input `font`.
:param `font`: an instance of :class:`Font`.
"""
new_font = wx.Font(font.GetPointSize(), font.GetFamily(), font.GetStyle(),
font.GetWeight(), font.GetUnderlined(),
font.GetFaceName(), font.GetEncoding())
return new_font
# ----------------------------------------------------------------------------
# HTMLHelpWindow is a frame containing the HTML help page for ShortcutEditor
# ----------------------------------------------------------------------------
class HTMLHelpWindow(wx.Frame):
"""
A simple :class:`Frame` container for the basic help provided to :class:`ShortcutEditor`.
The help page is actually straightly derived from:
http://graphicssoft.about.com/od/gimptutorials/tp/keyboard-shortcut-editor.htm
"""
def __init__(self, parent, htmlFile):
"""
Default class constructor.
:param `parent`: an instance of :class:`ShortcutEditor`;
:param string `htmlFile`: a valid HTML file containing either the default help
or your particular definition of help.
"""
wx.Frame.__init__(self, parent, title=_('Configure Keyboard Shortcuts Help'))
self.htmlFile = htmlFile
toolbar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.TB_TEXT|wx.TB_3DBUTTONS)
self.BuildToolBar(toolbar)
self.html = wx.html.HtmlWindow(self, style=wx.SUNKEN_BORDER)
self.printer = wx.html.HtmlEasyPrinting()
box = wx.BoxSizer(wx.VERTICAL)
box.Add(self.html, 1, wx.EXPAND)
self.SetSizer(box)
self.SetAutoLayout(True)
self.SetIcon(parent.GetIcon())
self.CreateStatusBar()
xvideo = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
yvideo = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
self.SetSize((xvideo/2, yvideo/2))
self.html.LoadFile(self.htmlFile)
self.Show()
def BuildToolBar(self, toolbar):
"""
Creates a toolbar for :class:`HTMLHelpWindow` containing the standard browsing
buttons like `Back`, `Forward`, `Home`, `Refresh` and `Print`.
:param `toolbar`: an instance of :class:`ToolBar`.
"""
w, h = _html_reload.GetBitmap().GetWidth(), _html_reload.GetBitmap().GetHeight()
toolbar.SetToolBitmapSize((w, h))
toolbar.AddLabelTool(wx.ID_BACKWARD, _('Back'), _html_back.GetBitmap(), shortHelp=_('Back'),
longHelp=_('Go to the previous page'))
toolbar.AddLabelTool(wx.ID_FORWARD, _('Forward'), _html_forward.GetBitmap(), shortHelp=_('Forward'),
longHelp=_('Go to the next page'))
toolbar.AddSeparator()
toolbar.AddLabelTool(wx.ID_HOME, _('Home'), _html_home.GetBitmap(), shortHelp=_('Home Page'),
longHelp=_('Go to the home page'))
toolbar.AddLabelTool(wx.ID_REFRESH, _('Refresh'), _html_reload.GetBitmap(), shortHelp=_('Refresh'),
longHelp=_('Refresh the current page'))
toolbar.AddSeparator()
toolbar.AddStretchableSpace()
toolbar.AddLabelTool(wx.ID_PRINT, _('Print'), _html_print.GetBitmap(), shortHelp=_('Print'),
longHelp=_('Print the current page'))
toolbar.Realize()
self.Bind(wx.EVT_TOOL, self.OnHTMLToolbar)
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI)
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnHTMLToolbar(self, event):
"""
Handles all the ``wx.EVT_TOOL`` events for :class:`HTMLHelpWindow`.
:param `event`: an instance of :class:`CommandEvent`.
"""
evId = event.GetId()
if evId == wx.ID_BACKWARD:
self.html.HistoryBack()
elif evId == wx.ID_FORWARD:
self.html.HistoryForward()
elif evId == wx.ID_HOME:
self.html.LoadFile(self.htmlFile)
elif evId == wx.ID_REFRESH:
self.html.LoadPage(self.html.GetOpenedPage())
elif evId == wx.ID_PRINT:
self.printer.GetPrintData().SetPaperId(wx.PAPER_LETTER)
self.printer.PrintFile(self.html.GetOpenedPage())
else:
raise Exception('Invalid toolbar item in HTMLHelpWindow')
def OnUpdateUI(self, event):
"""
Handles all the ``wx.EVT_UPDATE_UI`` events for :class:`HTMLHelpWindow`.
:param `event`: an instance of :class:`UpdateUIEvent`.
"""
evId = event.GetId()
if evId == wx.ID_BACKWARD:
event.Enable(self.html.HistoryCanBack())
elif evId == wx.ID_FORWARD:
event.Enable(self.html.HistoryCanForward())
else:
event.Skip()
def OnClose(self, event):
"""
Handles the ``wx.EVT_CLOSE`` event for :class:`HTMLHelpWindow`.
:param `event`: an instance of :class:`CloseEvent`.
"""
parent = self.GetParent()
self.Destroy()
parent.htmlWindow = None
event.Skip()
# ----------------------------------------------------------------------------
# ShortcutEvent is a special subclassing of wx.PyCommandEvent
# ----------------------------------------------------------------------------
class ShortcutEvent(wx.PyCommandEvent):
"""
:class:`ShortcutEvent` is a special subclassing of :class:`PyCommandEvent`.
This event gets emitted when the user is about to change a shortcut (via ``EVT_SHORTCUT_CHANGING``)
and when the user has changed a shortcut (via ``EVT_SHORTCUT_CHANGED``).
"""
def __init__(self, evtType, evtId, **kwargs):
"""
Default class constructor.
For internal use: do not call it in your code!
:param integer `evtType`: the event type;
:param integer `evtId`: the event identifier.
"""
wx.PyCommandEvent.__init__(self, evtType, evtId, **kwargs)
def GetAccelerator(self):
"""
Gets the shortcut string for which the operation was performed for ``EVT_SHORTCUT_CHANGED``
and ``EVT_SHORTCUT_CHANGING`` events.
:return: A string representing the new shortcut string (accelerator).
"""
return self.accelerator
def SetAccelerator(self, accelerator):
"""
Sets the shortcut string for which the operation was performed for ``EVT_SHORTCUT_CHANGED``
and ``EVT_SHORTCUT_CHANGING`` events.
:param string `accelerator`: a string representing the new shortcut string (accelerator).
"""
self.accelerator = accelerator
def GetOldAccelerator(self):
"""
Returns the previous shortcut string for ``EVT_SHORTCUT_CHANGED`` and
``EVT_SHORTCUT_CHANGING`` events.
:return: A string representing the old shortcut string (accelerator).
"""
return self.oldAccelerator
def SetOldAccelerator(self, accelerator):
"""
Sets the previous shortcut string for ``EVT_SHORTCUT_CHANGED`` and
``EVT_SHORTCUT_CHANGING`` events.
:param string `accelerator`: a string representing the old shortcut string (accelerator).
"""
self.oldAccelerator = accelerator
def SetShortcut(self, shortcut):
"""
Sets the shortcut class used for ``EVT_SHORTCUT_CHANGED`` and
``EVT_SHORTCUT_CHANGING`` events.
:param `shortcut`: an instance of :class:`Shortcut`.
"""
self.shortcut = shortcut
self.accelerator = shortcut.accelerator
def GetShortcut(self):
"""
Returns the shortcut class used for ``EVT_SHORTCUT_CHANGED`` and
``EVT_SHORTCUT_CHANGING`` events.
:return: An instance of :class:`Shortcut`.
"""
return self.shortcut
# ----------------------------------------------------------------------------
# Shortcut is a class containing the details for a shortcut, whether from
# a menu item, an accelerator or a user-defined shortcut. It behaves like
# a tree, with children and parents.
# ----------------------------------------------------------------------------
class Shortcut(object):
"""
:class:`Shortcut` is a class containing the details for a shortcut, whether from
a menu item, an accelerator or a user-defined shortcut. It behaves like
a tree, with children and parents.
"""
def __init__(self, label='', accelerator='', bitmap=wx.NullBitmap, help='',
menuItem=None, accelId=None):
"""
Default class constructor.
:param string `label`: the shortcut label string;
:param string `accelerator`: the shortcut accelerator string;
:param `bitmap`: an instance of :class:`Bitmap`, to display along the shortcut `label`
in the interface tree;
:param string `help`: the help string for this shortcut, to display in the interface tree;
:param `menuItem`: if this :class:`Shortcut` is derived from a :class:`MenuItem`, the :class:`MenuItem`
to which it should be associated;
:param integer `accelId`: if this :class:`Shortcut` is derived from an accelerator in a :class:`AcceleratorTable`
or from a custom, developer-defined shortcut, it represents the ID it is associated with.
"""
self.label = label
self.accelerator = accelerator
self.bitmap = bitmap
self.help = help
self.menuItem = menuItem
self.accelId = accelId
self.parent = None
self.topMenu = False
self.imageIndex = -1
self.changed = False
self.shown = True
self.position = None
self.originalAccelerator = accelerator
self.children = []
def AppendItem(self, item):
"""
Appends a :class:`Shortcut` item as a last child of its parent.
:param `item`: an instance of :class:`Shortcut`.
"""
item.parent = self
self.children.append(item)
def GetAccelerator(self):
""" Returns the string accelerator associated with this shortcut. """
return self.accelerator
def SetAccelerator(self, accelerator):
"""
Sets the string accelerator associated with this shortcut.
:param string `accelerator`: a string representing the shortcut string (accelerator).
"""
self.accelerator = accelerator
self.changed = False
if self.originalAccelerator != accelerator:
self.changed = True
def HasChanged(self):
"""
Returns ``True`` if the current accelerator associated with this :class:`Shortcut` is
different from the original one, ``False`` otherwise.
"""
return self.changed
def GetBitmap(self):
"""
Returns the bitmap associated with this :class:`Shortcut`.
:note: You should always check if the returned bitmap is a valid one or not::
bitmap = shortcut.GetBitmap()
if bitmap.IsOk():
DoSomething()
as the default bitmap associated with a :class:`Shortcut` is :class:`NullBitmap`.
"""
return self.bitmap
def SetBitmap(self, bitmap):
"""
Sets the bitmap associated with this :class:`Shortcut`.
:param `bitmap`: an instance of :class:`Bitmap` (can be invalid, i.e., :class:`NullBitmap`).
"""
self.bitmap = bitmap
def GetLabel(self):
""" Returns the string label associated with this shortcut. """
return self.label
def IsTop(self):
"""
Returns ``True`` if this :class:`Shortcut` is associated with a top-level :class:`Menu`,
(i.e., in the top :class:`MenuBar` level), ``False`` otherwise.
"""
return self.topMenu
def GetFirstChild(self, item):
"""
Returns this :class:`Shortcut`'s first child and an integer value 'cookie'.
Call :meth:`~Shortcut.GetNextChild` for the next child using this very 'cookie' return
value as an input.
:param `item`: an instance of :class:`Shortcut`.
:return: A tuple with the first value being an instance of :class:`Shortcut` or ``None`` if there are no
further children, and as second value an integer parameter 'cookie'.
:note: This method returns ``None`` if there are no further children.
"""
cookie = 0
return self.GetNextChild(item, cookie)
def GetNextChild(self, item, cookie):
"""
Returns this :class:`Shortcut`'s next child.
:param `item`: an instance of :class:`Shortcut`;
:param integer `cookie`: a parameter which is opaque for the application but is necessary
for the library to make this function reentrant (i.e. allow more than one
enumeration on one and the same object simultaneously).
:return: A tuple with the first value being an instance of :class:`Shortcut` or ``None`` if there are no
further children, and as second value an integer parameter 'cookie'.
:note: This method returns ``None`` if there are no further children.
"""
children = item.children
if cookie < len(children):
return children[cookie], cookie + 1
return None, cookie
def GetImageIndex(self):
""" Returns an integer index to be used in the :class:`ListShortcut` own :class:`ImageList`. """
return self.imageIndex
def CheckAccelerator(self, item, shortcut, accelerator):
"""
Checks if a shortcut string entered by the user has already been taken by another entry
in the :class:`Shortcut` hierarchy.
:param `item`: an instance of :class:`Shortcut`;
:param `shortcut`: another instance of :class:`Shortcut`, to compare with the previous `item`;
:param string `accelerator`: the user-edited accelerator string to check.
:return: An instance of :class:`Shortcut` if the shortcut string entered by the user conflicts
with an existing one, ``None`` otherwise.
"""
child, cookie = self.GetFirstChild(item)
while child:
existingAccel = child.accelerator.lower().split('+')
existingAccel.sort()
if existingAccel == accelerator and shortcut != child:
return child
conflict = self.CheckAccelerator(child, shortcut, accelerator)
if conflict:
return conflict
child, cookie = self.GetNextChild(item, cookie)
return None
def Match(self, filter=u'', item=None):
"""
Matches this :class:`Shortcut` label string against the `filter` input variable.
:param string `filter`: a string to match;
:param `item`: an instance of :class:`Shortcut`: its label string is compared with
the `filter` string to look for a match.
:return: An instance of :class:`Shortcut` if the `filter` string is contained in
the `item` lable, ``None`` otherwise.
:note: The string-matching is case-insensitive.
"""
if item is None:
item = self
child, cookie = self.GetFirstChild(item)
while child:
if filter in child.label.lower():
self.ShowHierarchy(child)
self.Match(filter, child)
child, cookie = self.GetNextChild(item, cookie)
def ShowHierarchy(self, item):
"""
Set the status of this :class:`Shortcut` ans its parent as `shown` in the
:class:`ListShortcut` tree hierarchy.
:param `item`: an instance of :class:`Shortcut`.
"""
item.shown = True
parent = item.parent
while parent:
parent.shown = True
parent = parent.parent
def ResetVisibility(self, item=None):
"""
Set the status of this :class:`Shortcut` and its parent as `hidden` in the
:class:`ListShortcut` tree hierarchy.
:param `item`: an instance of :class:`Shortcut`, used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously).
"""
if item is None:
item = self
child, cookie = self.GetFirstChild(item)
while child:
child.shown = False
item.shown = False
self.ResetVisibility(child)
child, cookie = self.GetNextChild(item, cookie)
def Get(self, label, item=None):
"""
Returns an instance of :class:`Shortcut` whose label matches the input `label` string.
:param string `label`: the string label to compare against this :class:`Shortcut` label;
:param `item`: an instance of :class:`Shortcut`, used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously).
:return: An instance of :class:`Shortcut` or ``None`` if no match was found.
"""
if item is None:
item = self
child, cookie = self.GetFirstChild(item)
retChild = None
while child:
if child.label.lower() == label.lower():
return child
retChild = self.Get(label, child)
child, cookie = self.GetNextChild(item, cookie)
return retChild
def GetById(self, id, item=None):
"""
Returns an instance of :class:`Shortcut` whose ID matches the input `id`.
:param integer `id`: an integer ID to compare against this :class:`Shortcut` id;
:param `item`: an instance of :class:`Shortcut`, used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously).
:return: An instance of :class:`Shortcut` or ``None`` if no match was found.
"""
if item is None:
item = self
child, cookie = self.GetFirstChild(item)
retChild = None
while child:
if child.menuItem and child.menuItem.GetId() == id:
return child
elif child.accelId == id:
return child
retChild = self.GetById(id, child)
child, cookie = self.GetNextChild(item, cookie)
return retChild
def GetId(self):
""" Returns this :class:`Shortcut` ID. """
if self.menuItem is not None:
if isinstance(self.menuItem, wx.Menu):
return 1
return self.menuItem.GetId()
return self.accelId
def RestoreDefaults(self, item=None):
"""
Restore the original shortcut string for this :class:`Shortcut`.
:param `item`: an instance of :class:`Shortcut`, used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously).
"""
if item is None:
item = self
child, cookie = self.GetFirstChild(item)
while child:
child.accelerator = child.originalAccelerator
child.changed = False
self.RestoreDefaults(child)
child, cookie = self.GetNextChild(item, cookie)
def FromMenuItem(self):
"""
Constructs this :class:`Shortcut` starting from a :class:`Menu` or :class:`MenuItem`.
The attributes needed to properly construct a :class:`Shortcut` are the label,
the accelerator string, the help string (optional) and the bitmap associated
with it (optional).
"""
if self.menuItem is None:
return
menuItem = self.menuItem
if isinstance(menuItem, wx.Menu):
label = menuItem.GetTitle()
accelerator = DISABLED_STRING
help = ''
bitmap = wx.NullBitmap
else:
label = menuItem.GetItemLabelText()
accelerator = menuItem.GetItemLabel()
if '\t' in accelerator:
accelerator = accelerator[accelerator.index('\t')+1:]
else:
accelerator = DISABLED_STRING
help = menuItem.GetHelp()
bitmap = menuItem.GetBitmap()
self.label = label
self.accelerator = accelerator
self.help = help
self.bitmap = bitmap
self.originalAccelerator = accelerator
def ToMenuItem(self, menuBar):
"""
Dumps this :class:`Shortcut` into a :class:`Menu` or :class:`MenuItem`.
The attributes needed to properly dump a :class:`Shortcut` into a :class:`Menu` or :class:`MenuBar`
are the label and the accelerator string.
:param `menuBar`: an instance of :class:`MenuBar`.
"""
if self.menuItem is None or not self.changed:
return
menuItem = self.menuItem
if isinstance(menuItem, wx.Menu):
if self.accelerator == DISABLED_STRING:
label = self.label
else:
label = '%s\t%s'%(self.label, self.accelerator)
menuBar.SetMenuLabel(menuItem.position, label)
else:
label = menuItem.GetItemLabel()
if '\t' in label:
label = label[0:label.index('\t')]
if self.accelerator != DISABLED_STRING:
label = '%s\t%s'%(label, self.accelerator)
menuBar.SetLabel(menuItem.GetId(), label)
def ToAcceleratorItem(self, table):
"""
Dumps this :class:`Shortcut` into a tuple of 3 elements:
* **flags**: a bitmask of ``wx.ACCEL_ALT``, ``wx.ACCEL_SHIFT``, ``wx.ACCEL_CTRL``, ``wx.ACCEL_CMD``
or ``wx.ACCEL_NORMAL`` used to specify which modifier keys are held down;
* **keyCode**: the keycode to be detected (i.e., ord('b'), wx.WXK_F10, etc...);
* **cmdID**: the menu or control command ID to use for the accelerator event.
:param `table`: a list of tuples, with the above specifications.
"""
if self.menuItem is not None or not self.changed:
return
if self.GetId() is None:
return
accelerator = self.accelerator
accelId = self.accelId
split = accelerator.split('+')
modifiers, keyCode = split[0:-1], split[-1]
inv_Accel = dict(zip(ACCELERATORS.values(), ACCELERATORS.keys()))
inv_KeyMap = dict(zip(KEYMAP.values(), KEYMAP.keys()))
base = wx.ACCEL_NORMAL
for mod in modifiers:
base |= inv_Accel[mod]
if keyCode in inv_KeyMap:
keyCode = inv_KeyMap[keyCode]
else:
keyCode = ord(keyCode)
accelItem = (base, keyCode, accelId)
table.append(accelItem)
# ----------------------------------------------------------------------------
# ConflictDialog is a subclass of GenericMessageDialog, customized to look
# like the GIMP conflict dialog.
# ----------------------------------------------------------------------------
class ConflictDialog(GMD.GenericMessageDialog):
"""
:class:`ConflictDialog` is a subclass of :class:`GenericMessageDialog`, customized to look
like the GIMP conflict dialog. This class is used to resolve shortcut
conflicts when the user assigns a shortcut that is already taken by another
entry in the shortcut list.
"""
def __init__(self, parent, conflict):
"""
Default class constructor.
:param `parent`: an instance of :class:`ShortcutEditor`;
:param `conflict`: an instance of :class:`Shortcut`, representing the conflicting
shortcut.
"""
transDict = dict(shortcut=conflict.accelerator, item=conflict.label, group=conflict.parent.label)
message = _('Shortcut "%(shortcut)s" is already taken by\n"%(item)s" from the "%(group)s" group. ')%transDict
transDict = dict(item=conflict.label)
extendedMessage = _('Reassigning the shortcut will cause it to be removed from \n"%(item)s". ')%transDict
GMD.GenericMessageDialog.__init__(self, parent, message, _('Conflicting Shortcuts'),
wx.OK|wx.CANCEL|wx.ICON_EXCLAMATION)
self.SetOKLabel(_('Reassing shortcut '))
self.SetOKBitmap(_reassign.GetBitmap())
self.SetExtendedMessage(extendedMessage + '\n')
self.SetIcon(parent.GetParent().GetIcon())
# ----------------------------------------------------------------------------
# ListShortcut is a subclass of HyperTreeList, customized to look
# like the GIMP main shortcut list.
# ----------------------------------------------------------------------------
class ListShortcut(HTL.HyperTreeList, treemixin.ExpansionState):
"""
:class:`ListShortcut` is a subclass of :class:`HyperTreeList`, customized to look
like the GIMP main shortcut list. This class is used to display the
shortcut label (with an optional bitmap next to it), its accelerator and
the help string associated with it (if present).
This information is displayed in 3 columns inside :class:`ListShortcut`.
"""
def __init__(self, parent):
"""
Default class constructor.
:param `parent`: an instance of :class:`ShortcutEditor`.
"""
HTL.HyperTreeList.__init__(self, parent, style=wx.BORDER_THEME,
agwStyle=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|
wx.TR_FULL_ROW_HIGHLIGHT|HTL.TR_ELLIPSIZE_LONG_ITEMS)
self.SetBackgroundColour(wx.WHITE)
self.AddColumn(_('Action'))
self.AddColumn(_('Shortcut'))
self.AddColumn(_('Help Label'))
self.SetMainColumn(0) # the one with the tree in it...
self.AddRoot('')
self.CalculateOffset()
self.selectedItem = None
self.hookBound = False
self.filter = u''
self.expansionState = []
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)
self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnExpandCollapse)
self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnExpandCollapse)
mainWindow = self.GetMainWindow()
mainWindow.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
mainWindow.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
def CalculateOffset(self):
"""
Calculates an offset (in pixels) so that the :class:`Shortcut` items without
a bitmap look parallel to the ones with a bitmap.
"""
dc = wx.MemoryDC()
dc.SelectObject(wx.EmptyBitmap(20, 20))
dc.SetFont(self.GetFont())
space = 0
text = ''
while space < 15:
space, dummy = dc.GetTextExtent(text)
text += ' '
dc.SelectObject(wx.NullBitmap)
self.offset = text
boldFont = FontFromFont(self.GetFont())
boldFont.SetWeight(wx.BOLD)
self.boldFont = boldFont
def Populate(self, item=None, shortcut=None):
"""
Recursively populates the :class:`ListShortcut` with information from the :class:`Shortcut` tree.
:param `item`: an instance of :class:`GenericTreeItem`. If ``None``, it is defaulted to
the :class:`ListShortcut` root item to make this function reentrant (i.e. allow more than one
enumeration on one and the same object simultaneously);
:param `shortcut`: an instance of :class:`Shortcut`. If ``None``, it is defaulted to
`self.manager` to make this function reentrant (i.e. allow more than one
enumeration on one and the same object simultaneously).
"""
if shortcut is None:
shortcut = self.manager
item = self.GetRootItem()
for child in shortcut.children:
if not child.shown:
continue
image = child.GetImageIndex()
label = child.label
if image < 0:
if not child.IsTop():
label = self.offset + label
newItem = self.AppendItem(item, label, data=child)
else:
newItem = self.AppendItem(item, label, image=image, data=child)
if child.IsTop():
self.SetItemFont(newItem, self.boldFont)
self.SetItemText(newItem, child.accelerator, 1)
self.SetItemText(newItem, child.help, 2)
colour = (child.HasChanged() and [wx.RED] or [wx.BLACK])[0]
self.SetItemTextColour(newItem, colour)
self.Populate(newItem, child)
def MakeImageList(self):
""" Builds the :class:`ListShortcut` image list based on the bitmaps in the :class:`Shortcut` hierarchy. """
self.imageList = wx.ImageList(16, 16)
self.BuildImageList()
self.AssignImageList(self.imageList)
def BuildImageList(self, shortcut=None, index=None):
"""
Recursively builds the :class:`ListShortcut` image list based on the bitmaps in the
:class:`Shortcut` hierarchy.
:param `shortcut`: an instance of :class:`Shortcut`. If ``None``, it is defaulted to
`self.manager` to make this function reentrant (i.e. allow more than one
enumeration on one and the same object simultaneously);
:param integer `index`: the current image index inside the :class:`ListShortcut` own :class:`ImageList`.
"""
if shortcut is None:
shortcut = self.manager
index = 0
for child in shortcut.children:
bitmap = child.GetBitmap()
if bitmap.IsOk():
self.imageList.Add(bitmap)
child.imageIndex = index
index += 1
index = self.BuildImageList(child, index)
return index
def GetItemIdentity(self, item):
"""
Return a hashable object that represents the identity of a :class:`ListShortcut` item.
In this implementation this returns the item label.
:param `item`: an instance of :class:`GenericTreeItem`.
"""
return self.GetItemText(item)
def OnSelChanged(self, event):
"""
Handles the ``wx.EVT_TREE_SEL_CHANGED`` event for :class:`ListShortcut`.
:param `event`: an instance of :class:`TreeEvent`.
"""
selectedItem = event.GetItem()
if selectedItem != self.selectedItem:
if self.selectedItem is not None:
pydata = self.GetPyData(self.selectedItem)
self.SetItemText(self.selectedItem, pydata.accelerator, 1)
else:
pydata = self.GetPyData(selectedItem)
if pydata.GetId() is not None:
self.SetItemText(selectedItem, NEW_ACCEL_STRING, 1)
else:
pydata = self.GetPyData(selectedItem)
self.SetItemText(selectedItem, pydata.accelerator, 1)
self.selectedItem = selectedItem
self.ShowShortcutText(False)
def OnExpandCollapse(self, event):
"""
Handles the ``wx.EVT_TREE_ITEM_COLLAPSED`` / ``wx.EVT_TREE_ITEM_EXPANDED`` events for :class:`ListShortcut`.
:param `event`: an instance of :class:`TreeEvent`.
"""
event.Skip()
self.expansionState = self.GetExpansionState()
def OnLeftDown(self, event):
"""
Handles the ``wx.EVT_LEFT_DOWN`` event for :class:`ListShortcut`.
:param `event`: an instance of :class:`MouseEvent`.
"""
if not self.hookBound:
self.GetParent().Bind(wx.EVT_CHAR_HOOK, self.OnShortcut)
self.hookBound = True
currentItem, flags, column = self.HitTest(event.GetPosition())
if self.selectedItem is None or not currentItem:
event.Skip()
return
pydata = self.GetPyData(currentItem)
if pydata.GetId() is None:
event.Skip()
return
if self.GetItemText(currentItem, 1) != NEW_ACCEL_STRING:
self.SetItemText(currentItem, NEW_ACCEL_STRING, 1)
else:
self.SetItemText(currentItem, pydata.accelerator, 1)
event.Skip()
def OnKillFocus(self, event):
"""
Handles the ``wx.EVT_KILL_FOCUS`` event for :class:`ListShortcut`.
:param `event`: an instance of :class:`FocusEvent`.
"""
self.GetParent().Unbind(wx.EVT_CHAR_HOOK)
self.hookBound = False
self.ShowShortcutText(False)
if self.selectedItem:
pydata = self.GetPyData(self.selectedItem)
self.SetItemText(self.selectedItem, pydata.accelerator, 1)
event.Skip()
def OnShortcut(self, event):
"""
Handles the ``wx.EVT_CHAR_HOOK`` event for :class:`ShortcutEditor`, implemented in :class:`ListShortcut`
as it is easier to deal with in this class.
:param `event`: an instance of :class:`KeyEvent`.
"""
if self.selectedItem is None:
# How did we get here???
event.Skip()
return
pydata = self.GetPyData(self.selectedItem)
currentText = self.GetItemText(self.selectedItem, 1)
if pydata.GetId() is None:
# Don't allow to change labels for shortcuts without an ID
event.Skip()
return
self.ShowShortcutText(True)
textCtrl = self.GetParent().hiddenText
keyCode = event.GetKeyCode()
modifiers = event.GetModifiers()
# If we press backspace with no modifers down, *and* the current text is
# "New accelerator..." then we reset the accelerator to "Disabled"
if keyCode == wx.WXK_BACK and modifiers == 0 and currentText in [NEW_ACCEL_STRING, DISABLED_STRING]:
accelerator = DISABLED_STRING
if not self.FireShortcutChanging(pydata, accelerator):
return
pydata.SetAccelerator(accelerator)
self.SetItemText(self.selectedItem, pydata.accelerator, 1)
colour = (pydata.HasChanged() and [wx.RED] or [wx.BLACK])[0]
self.SetItemTextColour(self.selectedItem, colour)
self.ShowShortcutText(False)
self.FireShortcutChanged(pydata, accelerator)
return
newContent = ''
for mod_int, mod_name in MODIFIERS:
if modifiers & mod_int == 0:
continue
newContent += mod_name + '+'
if newContent.strip():
textCtrl.ChangeValue(newContent)
accelerator = ''
if keyCode in KEYMAP:
accelerator = newContent + KEYMAP[keyCode]
else:
try:
toChar = chr(keyCode)
accelerator = newContent + toChar
except ValueError:
pass
if accelerator:
if not self.FireShortcutChanging(pydata, accelerator):
return
if self.AcceptShortcut(pydata, accelerator):
pydata.SetAccelerator(accelerator)
self.SetItemText(self.selectedItem, pydata.accelerator, 1)
colour = (pydata.HasChanged() and [wx.RED] or [wx.BLACK])[0]
self.SetItemTextColour(self.selectedItem, colour)
self.ShowShortcutText(False)
self.FireShortcutChanged(pydata, accelerator)
def AcceptShortcut(self, shortcut, accelerator):
"""
Returns ``True`` if the input `accelerator` is a valid shortcut, ``False`` otherwise.
:param `shortcut`: an instance of :class:`Shortcut`;
:param string `accelerator`: the new accelerator to check.
:note: Conflicting shortcuts are handled inside this method by presenting the user with
a conflict dialog. At this point the user can decide to reassign an existing shortcut
or to back away, in which case this method will return ``False``.
"""
sortedAccel = accelerator.lower().split('+')
sortedAccel.sort()
conflict = self.manager.CheckAccelerator(self.manager, shortcut, sortedAccel)
if conflict is None:
return True
dlg = ConflictDialog(self.GetParent(), conflict)
if dlg.ShowModal() == wx.ID_OK:
self.DisableShortcut(conflict)
dlg.Destroy()
return True
dlg.Destroy()
return False
def DisableShortcut(self, conflict, item=None):
"""
If the user decides to reassign a shortcut to another item, this method will disable
the conflicting shortcut (by putting a "Disabled" string as its accelerator).
:param `conflict`: an instance of :class:`Shortcut` to reset;
:param `item`: an instance of :class:`GenericTreeItem`. If defaulted to ``None``, it is set
to the :class:`ListShortcut` root item and used only to make this function reentrant
(i.e. allow more than one enumeration on one and the same object simultaneously).
"""
if item is None:
item = self.GetRootItem()
child, cookie = self.GetFirstChild(item)
while child:
if child.GetData() == conflict:
conflict.SetAccelerator(DISABLED_STRING)
self.SetItemText(child, conflict.accelerator, 1)
colour = (conflict.HasChanged() and [wx.RED] or [wx.BLACK])[0]
self.SetItemTextColour(child, colour)
return
self.DisableShortcut(conflict, child)
child, cookie = self.GetNextChild(item, cookie)
def FireShortcutChanging(self, shortcut, newAccel):
"""
Fires the ``EVT_SHORTCUT_CHANGING`` event for :class:`ListShortcut`.
The event propagation (and thus the shortcut renaming by the user) can be
interrupted by *not* calling `event.Skip()` in your handler for this event.
:param `shortcut`: an instance of :class:`Shortcut` that is about to be renamed;
:param string `newAccel`: the new accelerator just entered by the user.
"""
event = ShortcutEvent(wxEVT_SHORTCUT_CHANGING, self.GetId())
event.SetShortcut(shortcut)
event.oldAccelerator = shortcut.accelerator
event.accelerator = newAccel
event.SetEventObject(self)
if self.GetEventHandler().ProcessEvent(event):
# the caller didn't use event.Skip()
return False
return True
def FireShortcutChanged(self, shortcut, newAccel):
"""
Fires the ``EVT_SHORTCUT_CHANGED`` event for :class:`ListShortcut`.
:param `shortcut`: an instance of :class:`Shortcut` that has been renamed;
:param string `newAccel`: the new accelerator just entered by the user.
"""
event = ShortcutEvent(wxEVT_SHORTCUT_CHANGED, self.GetId())
event.SetShortcut(shortcut)
event.oldAccelerator = shortcut.accelerator
event.accelerator = newAccel
event.SetEventObject(self)
self.GetEventHandler().ProcessEvent(event)
return True
def ShowShortcutText(self, show):
"""
Shows/Hides a :class:`TextCtrl` used to display the combination of keystrokes the user
has entered. This :class:`TextCtrl` remains visible only for a short amount of time
and only when some keys are down.
:param bool `show`: ``True`` to show the :class:`TextCtrl`, ``False`` to hide it.
"""
textCtrl = self.GetParent().hiddenText
if show and not textCtrl.IsShown():
textCtrl.Show()
elif not show and textCtrl.IsShown():
textCtrl.Hide()
def SetFilter(self, filter=u''):
"""
Sets the `filter` string against all the shortcuts in the :class:`ListShortcut` are matched.
:param string `filter`: a string to match.
"""
self.filter = filter
self.manager.ResetVisibility()
self.manager.Match(filter)
self.RecreateTree()
def RecreateTree(self):
""" Recreates the entire :class:`ListShortcut` (columns excluded). """
self.Freeze()
self.DeleteAllItems()
self.AddRoot(u'')
self.Populate()
if not self.expansionState:
# Only the root item
self.ExpandAll()
else:
self.SetExpansionState(self.expansionState)
self.Thaw()
def HasFlag(self, flag):
"""
Overridden from :class:`Window` as a workaround on the conflicts between `treemixin` and
:class:`HyperTreeList` with the ``wx.TR_HIDE_ROOT`` `agwStyle` set.
:param integer `flag`: an integer bit flag specifying the `agwStyle` style.
:return: ``True`` if the :class:`ListShortcut` has the input `flag` set, ``False`` otherwise.
:note: Overridden from :class:`Window`.
"""
return self.HasAGWFlag(flag)
# ----------------------------------------------------------------------------
# ShortcutEditor is a subclass of wx.Dialog, customized to look
# like the GIMP main shortcut dialog.
# ----------------------------------------------------------------------------
class ShortcutEditor(wx.Dialog):
"""
:class:`ShortcutEditor` is a widget that allows the user to customize and change keyboard
shortcuts via a dialog. It can be used to edit :class:`MenuItem` shortcuts or accelerators
defined in a :class:`AcceleratorTable`.
The interface itself is very much inpired by the GIMP shortcut editor:
http://graphicssoft.about.com/od/gimptutorials/tp/keyboard-shortcut-editor.htm
There are very few minor UI differences between :class:`ShortcutEditor` and the GIMP one,
although the behaviour should be pretty much equivalent.
"""
def __init__(self, parent):
"""
Default class constructor.
:param `parent`: an instance of :class:`Window`, it can also be ``None``.
"""
wx.Dialog.__init__(self, parent, title=_('Configure Keyboard Shortcuts'),
style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
self.htmlFile = os.path.join(DATA_DIR, 'default_help_text.html')
self.htmlWindow = None
self.CreateWidgets()
self.DoLayout()
self.BindEvents()
if parent is not None and isinstance(parent, wx.TopLevelWindow):
self.SetIcon(parent.GetIcon())
self.Init()
def CreateWidgets(self):
"""
Creates all the widgets needed to populate the interface, such as buttons,
texts and, most importantly, :class:`ListShortcut`.
"""
self.topStatic = wx.StaticText(self, -1, _('&Search:'))
self.searchText = wx.TextCtrl(self, -1, '')
clearBmp = _clear.GetBitmap()
self.clearButton = wx.BitmapButton(self, wx.ID_CLEAR, clearBmp, style=wx.NO_BORDER)
self.listShortcut = ListShortcut(self)
self.hiddenText = wx.TextCtrl(self, -1, '', style=wx.BORDER_THEME)
w, h, d, e = self.hiddenText.GetFullTextExtent('Ctrl+Shift+Alt+q+g+M', self.hiddenText.GetFont())
self.hiddenText.SetMinSize((w, h+d-e+1))
defaultBmp = _default.GetBitmap()
self.defaultButton = buttons.ThemedGenBitmapTextButton(self, wx.ID_RESET, defaultBmp,
_('Restore Defaults '), size=(-1, 29))
self.infoBitmap = wx.StaticBitmap(self, -1, _info.GetBitmap())
message = _('To edit a shortcut key, click on the corresponding row\n' \
'and type a new accelerator, or press backspace to clear.')
italicFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
italicFont.SetStyle(wx.ITALIC)
self.infoStatic = wx.StaticText(self, -1, message)
self.infoStatic.SetFont(italicFont)
okBmp = _ok.GetBitmap()
cancelBmp = _cancel.GetBitmap()
helpBmp = _help.GetBitmap()
self.okButton = buttons.ThemedGenBitmapTextButton(self, wx.ID_OK, okBmp, _('OK'))
self.cancelButton = buttons.ThemedGenBitmapTextButton(self, wx.ID_CANCEL, cancelBmp, _('Cancel'))
self.helpButton = buttons.ThemedGenBitmapTextButton(self, wx.ID_HELP, helpBmp, _('Help'))
self.okButton.SetDefault()
def DoLayout(self):
""" Lays out the widgets using sizers in a platform-independent way. """
mainSizer = wx.BoxSizer(wx.VERTICAL)
topSizer = wx.BoxSizer(wx.HORIZONTAL)
mainSizer.Add((0, 5))
topSizer.Add(self.topStatic, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 5)
topSizer.Add(self.searchText, 1, wx.RIGHT, 5)
topSizer.Add(self.clearButton, 0, wx.ALIGN_CENTER_VERTICAL)
mainSizer.Add(topSizer, 0, wx.ALL|wx.EXPAND, 10)
mainSizer.Add(self.listShortcut, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 10)
mainSizer.Add((0, 5))
hiddenSizer = wx.BoxSizer(wx.HORIZONTAL)
hiddenSizer.Add(self.hiddenText, 0, wx.LEFT|wx.RIGHT|wx.RESERVE_SPACE_EVEN_IF_HIDDEN, 10)
hiddenSizer.Add((1, 0), 1, wx.EXPAND)
hiddenSizer.Add(self.defaultButton, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 10)
mainSizer.Add(hiddenSizer, 0, wx.EXPAND|wx.BOTTOM, 5)
centerSizer = wx.BoxSizer(wx.HORIZONTAL)
centerSizer.Add(self.infoBitmap, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 10)
centerSizer.Add(self.infoStatic, 1, wx.ALIGN_CENTER)
mainSizer.Add(centerSizer, 0, wx.TOP|wx.BOTTOM|wx.RIGHT, 10)
otherSizer = wx.BoxSizer(wx.HORIZONTAL)
# Add the fancy buttons
otherSizer.Add(self.okButton, 0, wx.ALL, 10)
otherSizer.Add((0, 0), 1, wx.EXPAND)
otherSizer.Add(self.cancelButton, 0, wx.LEFT|wx.TOP|wx.BOTTOM, 10)
otherSizer.Add(self.helpButton, 0, wx.ALL, 10)
mainSizer.Add(otherSizer, 0, wx.EXPAND|wx.TOP, 5)
self.hiddenText.Hide()
self.SetSizer(mainSizer)
mainSizer.Layout()
def BindEvents(self):
"""
Binds a few events we will need to process:
* ``wx.EVT_TEXT`` for the label filtering;
* ``wx.EVT_BUTTON`` for clearing the filtering, for the HTML help window and
to reset all the shortcuts to their defaults.
"""
self.searchText.Bind(wx.EVT_TEXT, self.OnSetFilter)
self.clearButton.Bind(wx.EVT_BUTTON, self.OnClearFilter)
self.defaultButton.Bind(wx.EVT_BUTTON, self.OnRestoreDefaults)
self.helpButton.Bind(wx.EVT_BUTTON, self.OnHTMLHelp)
def Init(self):
""" Common initialization procedures. """
self.manager = Shortcut()
self.listShortcut.manager = self.manager
def FromMenuBar(self, topWindow):
"""
Builds the entire shortcut hierarchy starting from a :class:`MenuBar`.
:param `topWindow`: an instance of :class:`TopLevelWindow`, containing the :class:`MenuBar`
we wish to scan.
"""
def MenuItemSearch(menu, item):
for menuItem in menu.GetMenuItems():
label = menuItem.GetLabel()
if not label:
# It's a separator
continue
shortcutItem = Shortcut(menuItem=menuItem)
shortcutItem.FromMenuItem()
item.AppendItem(shortcutItem)
subMenu = menuItem.GetSubMenu()
if subMenu:
MenuItemSearch(subMenu, shortcutItem)
position = 0
for menu, name in topWindow.GetMenuBar().GetMenus():
shortcutItem = Shortcut(menuItem=menu)
shortcutItem.topMenu = True
shortcutItem.position = position
shortcutItem.FromMenuItem()
position += 1
self.manager.AppendItem(shortcutItem)
MenuItemSearch(menu, item=shortcutItem)
def ToMenuBar(self, topWindow):
"""
Dumps the entire shortcut hierarchy (for shortcuts associated with a :class:`MenuItem`), into
a :class:`MenuBar`, changing only the :class:`Menu` / :class:`MenuItem` labels (it does **not** rebuild
the :class:`MenuBar`).
:param `topWindow`: an instance of :class:`TopLevelWindow`, containing the :class:`MenuBar`
we wish to repopulate.
"""
def MenuItemSet(shortcut, menuBar):
child, cookie = shortcut.GetFirstChild(shortcut)
while child:
child.ToMenuItem(menuBar)
MenuItemSet(child, menuBar)
child, cookie = shortcut.GetNextChild(shortcut, cookie)
manager = self.GetShortcutManager()
menuBar = topWindow.GetMenuBar()
MenuItemSet(manager, menuBar)
def FromAcceleratorTable(self, accelTable):
"""
Builds the entire shortcut hierarchy starting from a modified version of a :class:`AcceleratorTable`.
:param `accelTable`: a modified version of :class:`AcceleratorTable`, is a list of tuples (4 elements per tuple),
populated like this::
accelTable = []
# Every tuple is defined in this way:
for label, flags, keyCode, cmdID in my_accelerators:
# label: the string used to show the accelerator into the ShortcutEditor dialog
# flags: a bitmask of wx.ACCEL_ALT, wx.ACCEL_SHIFT, wx.ACCEL_CTRL, wx.ACCEL_CMD,
# or wx.ACCEL_NORMAL used to specify which modifier keys are held down
# keyCode: the keycode to be detected (i.e., ord('b'), wx.WXK_F10, etc...)
# cmdID: the menu or control command ID to use for the accelerator event.
accel_tuple = (label, flags, keyCode, cmdID)
accelTable.append(accel_tuple)
"""
parentShortcut = Shortcut(_('Accelerators'))
parentShortcut.topMenu = True
self.manager.AppendItem(parentShortcut)
for text, modifier, accel, ids in accelTable:
modifier = ACCELERATORS[modifier]
if accel in KEYMAP:
accel = KEYMAP[accel]
else:
accel = chr(accel)
shortcut = (modifier and ['%s+%s'%(modifier, accel)] or [accel])[0]
shortcutItem = Shortcut(text, shortcut, accelId=ids)
parentShortcut.AppendItem(shortcutItem)
def ToAcceleratorTable(self, window):
"""
Dumps the entire shortcut hierarchy (for shortcuts associated with a :class:`AcceleratorTable`), into
a :class:`AcceleratorTable`. This method **does** rebuild the :class:`AcceleratorTable` and sets it back
to the input `window`.
:param `window`: an instance of :class:`Window`, to which the new :class:`AcceleratorTable` should be set.
"""
def AccelItemSet(shortcut, table):
child, cookie = shortcut.GetFirstChild(shortcut)
while child:
child.ToAcceleratorItem(table)
table = AccelItemSet(child, table)
child, cookie = shortcut.GetNextChild(shortcut, cookie)
return table
manager = self.GetShortcutManager()
table = AccelItemSet(manager, table=[])
window.SetAcceleratorTable(wx.AcceleratorTable(table))
def SetColumnWidths(self):
"""
Sets the :class:`ListShortcut` columns widths to acceptable and eye-pleasing
numbers (in pixels).
"""
total_width = 0
for col in xrange(self.listShortcut.GetColumnCount()):
self.listShortcut.SetColumnWidth(col, wx.LIST_AUTOSIZE)
width = self.listShortcut.GetColumnWidth(col)
if col == 0:
width += 20
elif col == 1:
width += 5
else:
width = min(width, 200)
width = max(50, width)
self.listShortcut.SetColumnWidth(col, width)
total_width += width
self.listShortcut.GetMainWindow()._lineHeight += 5
dialogHeight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)/2
self.SetSize((total_width+60, dialogHeight))
self.Center()
def OnSetFilter(self, event=None):
"""
Handles the ``wx.EVT_TEXT`` event for :class:`ShortcutEditor`.
:param `event`: if not ``None``, an instance of :class:`KeyEvent`.
"""
if event:
event.Skip()
filter = self.searchText.GetValue()
filter = filter.lower().strip()
self.listShortcut.SetFilter(filter)
def OnClearFilter(self, event):
"""
Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user clears the
label filter at the top of the user interface.
:param `event`: an instance of :class:`CommandEvent`.
"""
self.searchText.SetValue(u'')
def OnRestoreDefaults(self, event):
"""
Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user restores the
original shortcuts.
:param `event`: an instance of :class:`CommandEvent`.
"""
self.manager.RestoreDefaults()
self.listShortcut.RecreateTree()
def OnHTMLHelp(self, event):
"""
Handles the ``wx.EVT_BUTTON`` event for :class:`ShortcutEditor` when the user presses the ``Help``
button.
:param `event`: an instance of :class:`CommandEvent`.
.. note::
By default, this method launches a :class:`html.HtmlWindow` containing the default
HTML help file. If you wish to load another help file, you should call :meth:`~ShortcutEditor.SetHTMLHelpFile`
with another input HTML file.
"""
if self.htmlWindow:
self.htmlWindow.Show()
self.htmlWindow.Restore()
self.htmlWindow.Raise()
return
self.htmlWindow = HTMLHelpWindow(self, self.htmlFile)
def GetShortcutManager(self):
""" Returns the root :class:`Shortcut` containing the whole shortcut hierarchy. """
return self.manager
def SetHTMLHelpFile(self, htmlFile):
"""
Sets a new HTML help file (a valid html file) to be loaded when the user seeks
for an explanation on how the UI works.
:param string `htmlFile`: a valid HTML file.
"""
if not os.path.isfile(htmlFile):
raise Exception('Invalid HTML help file passed to ShortcutEditor')
self.htmlFile = htmlFile
if self.htmlWindow is not None:
self.htmlWindow.htmlFile = htmlFile
self.htmlWindow.LoadFile(self.htmlFile)
def PreShow(self):
""" Does some more common initialization before showing :class:`ShortcutEditor`. """
self.listShortcut.MakeImageList()
self.listShortcut.RecreateTree()
self.SetColumnWidths()
def ShowModal(self):
"""
Shows the :class:`ShortcutEditor` dialog in an application-modal way.
Program flow does not return until the dialog has been dismissed with `EndModal`.
:return: The value set with `SetReturnCode`.
.. note::
Notice that it is possible to call :meth:`~ShortcutEditor.ShowModal` for a dialog which had been
previously shown with :meth:`~ShortcutEditor.Show`, this allows to make an existing modeless dialog
modal. However :meth:`~ShortcutEditor.ShowModal` can't be called twice without intervening `EndModal` calls.
.. note::
Note that this function creates a temporary event loop which takes precedence
over the application's main event loop (see :class:`EventLoopBase`) and which is
destroyed when the dialog is dismissed. This also results in a call to
:meth:`App.ProcessPendingEvents` ().
"""
self.PreShow()
wx.Dialog.ShowModal(self)
def Show(self, show=True):
"""
Hides or shows the :class:`ShortcutEditor` dialog.
The preferred way of dismissing a modal dialog is to use `EndModal`.
:param bool `show`: if ``True``, the dialog box is shown and brought to the front,
otherwise the box is hidden. If ``False`` and the dialog is modal, control is
returned to the calling program.
:note: Reimplemented from :class:`Window`.
"""
self.PreShow()
wx.Dialog.Show(self, show)