Skip to content

StyleBuilderTTK

A class containing methods for building new ttk widget styles on demand.

The methods in this classed are used internally to generate ttk widget styles on-demand and are not intended to be called by the end user.

Source code in src/ttkbootstrap/style.py
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
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
class StyleBuilderTTK:
    """A class containing methods for building new ttk widget styles on
    demand.

    The methods in this classed are used internally to generate ttk
    widget styles on-demand and are not intended to be called by the end
    user.
    """

    def __init__(self, build: bool = True):
        self.style: Style = Style.get_instance()
        self.theme_images = {}
        self.builder_tk = StyleBuilderTK()

        if build:
            self.create_theme()

    @staticmethod
    def name_to_method(method_name):
        """Get a method by name.

        Parameters:

            method_name (str):
                The name of the style builder method.

        Returns:

            Callable:
                The method that is named by `method_name`
        """
        func = getattr(StyleBuilderTTK, method_name)
        return func

    @property
    def colors(self) -> Colors:
        """A reference to the `Colors` object of the current theme."""
        return self.style.theme.colors

    @property
    def theme(self) -> ThemeDefinition:
        """A reference to the `ThemeDefinition` object for the current
        theme."""
        return self.style.theme

    @property
    def is_light_theme(self) -> bool:
        """If the current theme is _light_, returns `True`, otherwise
        returns `False`."""
        return self.style.theme.type == LIGHT

    def scale_size(self, size):
        """Scale the size of images and other assets based on the
        scaling factor of ttk to ensure that the image matches the
        screen resolution.

        Parameters:

            size (Union[int, List, Tuple]):
                A single integer or an iterable of integers
        """
        winsys = self.style.master.tk.call("tk", "windowingsystem")
        if winsys == "aqua":
            BASELINE = 1.000492368291482
        else:
            BASELINE = 1.33398982438864281
        scaling = self.style.master.tk.call("tk", "scaling")
        factor = scaling / BASELINE

        if isinstance(size, int) or isinstance(size, float):
            return ceil(size * factor)
        elif isinstance(size, tuple) or isinstance(size, list):
            return [ceil(x * factor) for x in size]

    def create_theme(self):
        """Create and style a new ttk theme. A wrapper around internal
        style methods.
        """
        self.style.theme_create(self.theme.name, TTK_CLAM)
        ttk.Style.theme_use(self.style, self.theme.name)
        self.update_ttk_theme_settings()

    def update_ttk_theme_settings(self):
        """This method is called internally every time the theme is
        changed to update various components included in the body of
        the method."""
        self.create_default_style()

    def create_default_style(self):
        """Setup the default widget style configuration for the root
        ttk style "."; these defaults are applied to any widget that
        contains the configuration options updated by this style. This
        method should be called *first* before any other style is applied
        during theme creation.
        """
        self.style._build_configure(
            style=".",
            background=self.colors.bg,
            darkcolor=self.colors.border,
            foreground=self.colors.fg,
            troughcolor=self.colors.bg,
            selectbg=self.colors.selectbg,
            selectfg=self.colors.selectfg,
            selectforeground=self.colors.selectfg,
            selectbackground=self.colors.selectbg,
            fieldbg="white",
            borderwidth=1,
            focuscolor="",
        )
        # this is general style applied to the tableview
        self.create_link_button_style()
        self.style.configure("symbol.Link.TButton", font="-size 16")

        # this is the general style applied to the tooltip
        self.create_label_style()
        self.style.configure(
            style="tooltip.TLabel",
            background="#fffddd",
            foreground="#333",
            bordercolor="#888",
            borderwidth=1,
            darkcolor="#fffddd",
            lightcolor="#fffddd",
            relief=RAISED,
        )

    def create_combobox_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Combobox widget.

        Parameters:

            colorname (str):
                The color label to use as the primary widget color.
        """
        STYLE = "TCombobox"

        if self.is_light_theme:
            disabled_fg = self.colors.border
            bordercolor = self.colors.border
            readonly = self.colors.light
        else:
            disabled_fg = self.colors.selectbg
            bordercolor = self.colors.selectbg
            readonly = bordercolor

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            element = f"{ttkstyle.replace('TC', 'C')}"
            focuscolor = self.colors.primary
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            element = f"{ttkstyle.replace('TC', 'C')}"
            focuscolor = self.colors.get(colorname)

        # Create custom arrow assets since the default ones don't work with Tcl/Tk bundled in python 3.13
        arrow_images = self.create_simple_arrow_assets(
            self.colors.inputfg,
            disabled_fg,
            focuscolor,
        )
        downarrow_image = arrow_images[0][1]
        downarrow_disabled_image = arrow_images[1][1]
        downarrow_focused_image = arrow_images[2][1]
        self.style.element_create(
            f"{element}.downarrow",
            "image",
            downarrow_image,
            ("disabled", downarrow_disabled_image),
            ("pressed !disabled", downarrow_focused_image),
            ("focus !disabled", downarrow_focused_image),
            ("hover !disabled", downarrow_focused_image),
        )
        #  self.style.element_create(f"{element}.downarrow", "from", TTK_DEFAULT)  # doesn't work in python 3.13
        self.style.element_create(f"{element}.padding", "from", TTK_CLAM)
        self.style.element_create(f"{element}.textarea", "from", TTK_CLAM)

        if all([colorname, colorname != DEFAULT]):
            bordercolor = focuscolor

        self.style._build_configure(
            ttkstyle,
            bordercolor=bordercolor,
            darkcolor=self.colors.inputbg,
            lightcolor=self.colors.inputbg,
            foreground=self.colors.inputfg,
            fieldbackground=self.colors.inputbg,
            background=self.colors.inputbg,
            insertcolor=self.colors.inputfg,
            relief=tk.FLAT,
            padding=5,
        )
        self.style.map(
            ttkstyle,
            background=[("readonly", readonly)],
            fieldbackground=[("readonly", readonly)],
            foreground=[("disabled", disabled_fg)],
            bordercolor=[
                ("invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("hover !disabled", focuscolor),
            ],
            lightcolor=[
                ("focus invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("pressed !disabled", focuscolor),
                ("readonly", readonly),
            ],
            darkcolor=[
                ("focus invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("pressed !disabled", focuscolor),
                ("readonly", readonly),
            ],
        )
        self.style.layout(
            ttkstyle,
            [
                (
                    "combo.Spinbox.field",
                    {
                        "side": tk.TOP,
                        "sticky": tk.EW,
                        "children": [
                            (
                                "Combobox.downarrow",
                                {"side": tk.RIGHT, "sticky": tk.S},
                            ),
                            (
                                "Combobox.padding",
                                {
                                    "expand": "1",
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            "Combobox.textarea",
                                            {"sticky": tk.NSEW},
                                        )
                                    ],
                                },
                            ),
                        ],
                    },
                )
            ],
        )
        self.style._register_ttkstyle(ttkstyle)
        try:
            self.create_scrollbar_style()
        except Exception:
            # style already created
            pass

    def create_separator_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Separator widget.

        Parameters:

            colorname (str):
                The primary widget color.
        """
        HSTYLE = "Horizontal.TSeparator"
        VSTYLE = "Vertical.TSeparator"

        hsize = [40, 1]
        vsize = [1, 40]

        # style colors
        if self.is_light_theme:
            default_color = self.colors.border
        else:
            default_color = self.colors.selectbg

        if any([colorname == DEFAULT, colorname == ""]):
            background = default_color
            h_ttkstyle = HSTYLE
            v_ttkstyle = VSTYLE
        else:
            background = self.colors.get(colorname)
            h_ttkstyle = f"{colorname}.{HSTYLE}"
            v_ttkstyle = f"{colorname}.{VSTYLE}"

        # horizontal separator
        h_element = h_ttkstyle.replace(".TS", ".S")
        h_img = ImageTk.PhotoImage(Image.new("RGB", hsize, background))
        h_name = util.get_image_name(h_img)
        self.theme_images[h_name] = h_img

        self.style.element_create(f"{h_element}.separator", "image", h_name)
        self.style.layout(
            h_ttkstyle, [(f"{h_element}.separator", {"sticky": tk.EW})]
        )

        # vertical separator
        v_element = v_ttkstyle.replace(".TS", ".S")
        v_img = ImageTk.PhotoImage(Image.new("RGB", vsize, background))
        v_name = util.get_image_name(v_img)
        self.theme_images[v_name] = v_img
        self.style.element_create(f"{v_element}.separator", "image", v_name)
        self.style.layout(
            v_ttkstyle, [(f"{v_element}.separator", {"sticky": tk.NS})]
        )
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_striped_progressbar_assets(self, thickness, colorname=DEFAULT):
        """Create the striped progressbar image and return as a
        `PhotoImage`

        Parameters:

            colorname (str):
                The color label used to style the widget.

        Returns:

            tuple[str]:
                A list of photoimage names.
        """
        if any([colorname == DEFAULT, colorname == ""]):
            barcolor = self.colors.primary
        else:
            barcolor = self.colors.get(colorname)

        # calculate value of the light color
        brightness = Colors.rgb_to_hsv(*Colors.hex_to_rgb(barcolor))[2]
        if brightness < 0.4:
            value_delta = 0.3
        elif brightness > 0.8:
            value_delta = 0
        else:
            value_delta = 0.1

        barcolor_light = Colors.update_hsv(barcolor, sd=-0.2, vd=value_delta)

        # horizontal progressbar
        img = Image.new("RGBA", (100, 100), barcolor_light)
        draw = ImageDraw.Draw(img)
        draw.polygon(
            xy=[(0, 0), (48, 0), (100, 52), (100, 100)],
            fill=barcolor,
        )
        draw.polygon(xy=[(0, 52), (48, 100), (0, 100)], fill=barcolor)

        _resized = img.resize((thickness, thickness), Resampling.LANCZOS)
        h_img = ImageTk.PhotoImage(_resized)
        h_name = h_img._PhotoImage__photo.name
        v_img = ImageTk.PhotoImage(_resized.rotate(90))
        v_name = v_img._PhotoImage__photo.name

        self.theme_images[h_name] = h_img
        self.theme_images[v_name] = v_img
        return h_name, v_name

    def create_striped_progressbar_style(self, colorname=DEFAULT):
        """Create a striped style for the ttk.Progressbar widget.

        Parameters:

            colorname (str):
                The primary widget color label.
        """
        HSTYLE = "Striped.Horizontal.TProgressbar"
        VSTYLE = "Striped.Vertical.TProgressbar"

        thickness = self.scale_size(12)

        if any([colorname == DEFAULT, colorname == ""]):
            h_ttkstyle = HSTYLE
            v_ttkstyle = VSTYLE
        else:
            h_ttkstyle = f"{colorname}.{HSTYLE}"
            v_ttkstyle = f"{colorname}.{VSTYLE}"

        if self.is_light_theme:
            if colorname == LIGHT:
                troughcolor = self.colors.bg
                bordercolor = self.colors.light
            else:
                troughcolor = self.colors.light
                bordercolor = troughcolor
        else:
            troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)
            bordercolor = troughcolor

        # ( horizontal, vertical )
        images = self.create_striped_progressbar_assets(thickness, colorname)

        # horizontal progressbar
        h_element = h_ttkstyle.replace(".TP", ".P")
        self.style.element_create(
            f"{h_element}.pbar",
            "image",
            images[0],
            width=thickness,
            sticky=tk.EW,
        )
        self.style.layout(
            h_ttkstyle,
            [
                (
                    f"{h_element}.trough",
                    {
                        "sticky": tk.NSEW,
                        "children": [
                            (
                                f"{h_element}.pbar",
                                {"side": tk.LEFT, "sticky": tk.NS},
                            )
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(
            h_ttkstyle,
            troughcolor=troughcolor,
            thickness=thickness,
            bordercolor=bordercolor,
            borderwidth=1,
        )

        # vertical progressbar
        v_element = v_ttkstyle.replace(".TP", ".P")
        self.style.element_create(
            f"{v_element}.pbar",
            "image",
            images[1],
            width=thickness,
            sticky=tk.NS,
        )
        self.style.layout(
            v_ttkstyle,
            [
                (
                    f"{v_element}.trough",
                    {
                        "sticky": tk.NSEW,
                        "children": [
                            (
                                f"{v_element}.pbar",
                                {"side": tk.BOTTOM, "sticky": tk.EW},
                            )
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(
            v_ttkstyle,
            troughcolor=troughcolor,
            bordercolor=bordercolor,
            thickness=thickness,
            borderwidth=1,
        )
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_progressbar_style(self, colorname=DEFAULT):
        """Create a solid ttk style for the ttk.Progressbar widget.

        Parameters:

            colorname (str):
                The primary widget color.
        """
        H_STYLE = "Horizontal.TProgressbar"
        V_STYLE = "Vertical.TProgressbar"

        thickness = self.scale_size(10)

        if self.is_light_theme:
            if colorname == LIGHT:
                troughcolor = self.colors.bg
                bordercolor = self.colors.light
            else:
                troughcolor = self.colors.light
                bordercolor = troughcolor
        else:
            troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)
            bordercolor = troughcolor

        if any([colorname == DEFAULT, colorname == ""]):
            background = self.colors.primary
            h_ttkstyle = H_STYLE
            v_ttkstyle = V_STYLE
        else:
            background = self.colors.get(colorname)
            h_ttkstyle = f"{colorname}.{H_STYLE}"
            v_ttkstyle = f"{colorname}.{V_STYLE}"

        self.style._build_configure(
            h_ttkstyle,
            thickness=thickness,
            borderwidth=1,
            bordercolor=bordercolor,
            lightcolor=self.colors.border,
            pbarrelief=tk.FLAT,
            troughcolor=troughcolor,
        )
        existing_elements = self.style.element_names()

        self.style._build_configure(
            v_ttkstyle,
            thickness=thickness,
            borderwidth=1,
            bordercolor=bordercolor,
            lightcolor=self.colors.border,
            pbarrelief=tk.FLAT,
            troughcolor=troughcolor,
        )
        existing_elements = self.style.element_names()

        # horizontal progressbar
        h_element = h_ttkstyle.replace(".TP", ".P")
        trough_element = f"{h_element}.trough"
        pbar_element = f"{h_element}.pbar"
        if trough_element not in existing_elements:
            self.style.element_create(trough_element, "from", TTK_CLAM)
            self.style.element_create(pbar_element, "from", TTK_DEFAULT)

        self.style.layout(
            h_ttkstyle,
            [
                (
                    trough_element,
                    {
                        "sticky": "nswe",
                        "children": [
                            (pbar_element, {"side": "left", "sticky": "ns"})
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(h_ttkstyle, background=background)

        # vertical progressbar
        v_element = v_ttkstyle.replace(".TP", ".P")
        trough_element = f"{v_element}.trough"
        pbar_element = f"{v_element}.pbar"
        if trough_element not in existing_elements:
            self.style.element_create(trough_element, "from", TTK_CLAM)
            self.style.element_create(pbar_element, "from", TTK_DEFAULT)
            self.style._build_configure(v_ttkstyle, background=background)
        self.style.layout(
            v_ttkstyle,
            [
                (
                    trough_element,
                    {
                        "sticky": "nswe",
                        "children": [
                            (pbar_element, {"side": "bottom", "sticky": "we"})
                        ],
                    },
                )
            ],
        )

        # register ttkstyles
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_scale_assets(self, colorname=DEFAULT, size=14):
        """Create the assets used for the ttk.Scale widget.

        The slider handle is automatically adjusted to fit the
        screen resolution.

        Parameters:

            colorname (str):
                The color label.

            size (int):
                The size diameter of the slider circle; default=16.

        Returns:

            tuple[str]:
                A tuple of PhotoImage names to be used in the image
                layout when building the style.
        """
        size = self.scale_size(size)
        if self.is_light_theme:
            disabled_color = self.colors.border
            if colorname == LIGHT:
                track_color = self.colors.bg
            else:
                track_color = self.colors.light
        else:
            disabled_color = self.colors.selectbg
            track_color = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

        if any([colorname == DEFAULT, colorname == ""]):
            normal_color = self.colors.primary
        else:
            normal_color = self.colors.get(colorname)

        pressed_color = Colors.update_hsv(normal_color, vd=-0.1)
        hover_color = Colors.update_hsv(normal_color, vd=0.1)

        # normal state
        _normal = Image.new("RGBA", (100, 100))
        draw = ImageDraw.Draw(_normal)
        draw.ellipse((0, 0, 95, 95), fill=normal_color)
        normal_img = ImageTk.PhotoImage(
            _normal.resize((size, size), Resampling.LANCZOS)
        )
        normal_name = util.get_image_name(normal_img)
        self.theme_images[normal_name] = normal_img

        # pressed state
        _pressed = Image.new("RGBA", (100, 100))
        draw = ImageDraw.Draw(_pressed)
        draw.ellipse((0, 0, 95, 95), fill=pressed_color)
        pressed_img = ImageTk.PhotoImage(
            _pressed.resize((size, size), Resampling.LANCZOS)
        )
        pressed_name = util.get_image_name(pressed_img)
        self.theme_images[pressed_name] = pressed_img

        # hover state
        _hover = Image.new("RGBA", (100, 100))
        draw = ImageDraw.Draw(_hover)
        draw.ellipse((0, 0, 95, 95), fill=hover_color)
        hover_img = ImageTk.PhotoImage(
            _hover.resize((size, size), Resampling.LANCZOS)
        )
        hover_name = util.get_image_name(hover_img)
        self.theme_images[hover_name] = hover_img

        # disabled state
        _disabled = Image.new("RGBA", (100, 100))
        draw = ImageDraw.Draw(_disabled)
        draw.ellipse((0, 0, 95, 95), fill=disabled_color)
        disabled_img = ImageTk.PhotoImage(
            _disabled.resize((size, size), Resampling.LANCZOS)
        )
        disabled_name = util.get_image_name(disabled_img)
        self.theme_images[disabled_name] = disabled_img

        # vertical track
        h_track_img = ImageTk.PhotoImage(
            Image.new("RGB", self.scale_size((40, 5)), track_color)
        )
        h_track_name = util.get_image_name(h_track_img)
        self.theme_images[h_track_name] = h_track_img

        # horizontal track
        v_track_img = ImageTk.PhotoImage(
            Image.new("RGB", self.scale_size((5, 40)), track_color)
        )
        v_track_name = util.get_image_name(v_track_img)
        self.theme_images[v_track_name] = v_track_img

        return (
            normal_name,
            pressed_name,
            hover_name,
            disabled_name,
            h_track_name,
            v_track_name,
        )

    def create_scale_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Scale widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TScale"

        if any([colorname == DEFAULT, colorname == ""]):
            h_ttkstyle = f"Horizontal.{STYLE}"
            v_ttkstyle = f"Vertical.{STYLE}"
        else:
            h_ttkstyle = f"{colorname}.Horizontal.{STYLE}"
            v_ttkstyle = f"{colorname}.Vertical.{STYLE}"

        # ( normal, pressed, hover, disabled, htrack, vtrack )
        images = self.create_scale_assets(colorname)

        # horizontal scale
        h_element = h_ttkstyle.replace(".TS", ".S")
        self.style.element_create(
            f"{h_element}.slider",
            "image",
            images[0],
            ("disabled", images[3]),
            ("pressed", images[1]),
            ("hover", images[2]),
        )
        self.style.element_create(f"{h_element}.track", "image", images[4])
        self.style.layout(
            h_ttkstyle,
            [
                (
                    f"{h_element}.focus",
                    {
                        "expand": "1",
                        "sticky": tk.NSEW,
                        "children": [
                            (f"{h_element}.track", {"sticky": tk.EW}),
                            (
                                f"{h_element}.slider",
                                {"side": tk.LEFT, "sticky": ""},
                            ),
                        ],
                    },
                )
            ],
        )
        # vertical scale
        v_element = v_ttkstyle.replace(".TS", ".S")
        self.style.element_create(
            f"{v_element}.slider",
            "image",
            images[0],
            ("disabled", images[3]),
            ("pressed", images[1]),
            ("hover", images[2]),
        )
        self.style.element_create(f"{v_element}.track", "image", images[5])
        self.style.layout(
            v_ttkstyle,
            [
                (
                    f"{v_element}.focus",
                    {
                        "expand": "1",
                        "sticky": tk.NSEW,
                        "children": [
                            (f"{v_element}.track", {"sticky": tk.NS}),
                            (
                                f"{v_element}.slider",
                                {"side": tk.TOP, "sticky": ""},
                            ),
                        ],
                    },
                )
            ],
        )
        # register ttkstyles
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_floodgauge_style(self, colorname=DEFAULT):
        """Create a ttk style for the ttkbootstrap.widgets.Floodgauge
        widget. This is a custom widget style that uses components of
        the progressbar and label.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        HSTYLE = "Horizontal.TFloodgauge"
        VSTYLE = "Vertical.TFloodgauge"
        FLOOD_FONT = "-size 14"

        if any([colorname == DEFAULT, colorname == ""]):
            h_ttkstyle = HSTYLE
            v_ttkstyle = VSTYLE
            background = self.colors.primary
        else:
            h_ttkstyle = f"{colorname}.{HSTYLE}"
            v_ttkstyle = f"{colorname}.{VSTYLE}"
            background = self.colors.get(colorname)

        if colorname == LIGHT:
            foreground = self.colors.fg
            troughcolor = self.colors.bg
        else:
            troughcolor = Colors.update_hsv(background, sd=-0.3, vd=0.8)
            foreground = self.colors.selectfg

        # horizontal floodgauge
        h_element = h_ttkstyle.replace(".TF", ".F")
        self.style.element_create(f"{h_element}.trough", "from", TTK_CLAM)
        self.style.element_create(f"{h_element}.pbar", "from", TTK_DEFAULT)
        self.style.layout(
            h_ttkstyle,
            [
                (
                    f"{h_element}.trough",
                    {
                        "children": [
                            (f"{h_element}.pbar", {"sticky": tk.NS}),
                            ("Floodgauge.label", {"sticky": ""}),
                        ],
                        "sticky": tk.NSEW,
                    },
                )
            ],
        )
        self.style._build_configure(
            h_ttkstyle,
            thickness=50,
            borderwidth=1,
            bordercolor=background,
            lightcolor=background,
            pbarrelief=tk.FLAT,
            troughcolor=troughcolor,
            background=background,
            foreground=foreground,
            justify=tk.CENTER,
            anchor=tk.CENTER,
            font=FLOOD_FONT,
        )
        # vertical floodgauge
        v_element = v_ttkstyle.replace(".TF", ".F")
        self.style.element_create(f"{v_element}.trough", "from", TTK_CLAM)
        self.style.element_create(f"{v_element}.pbar", "from", TTK_DEFAULT)
        self.style.layout(
            v_ttkstyle,
            [
                (
                    f"{v_element}.trough",
                    {
                        "children": [
                            (f"{v_element}.pbar", {"sticky": tk.EW}),
                            ("Floodgauge.label", {"sticky": ""}),
                        ],
                        "sticky": tk.NSEW,
                    },
                )
            ],
        )
        self.style._build_configure(
            v_ttkstyle,
            thickness=50,
            borderwidth=1,
            bordercolor=background,
            lightcolor=background,
            pbarrelief=tk.FLAT,
            troughcolor=troughcolor,
            background=background,
            foreground=foreground,
            justify=tk.CENTER,
            anchor=tk.CENTER,
            font=FLOOD_FONT,
        )
        # register ttkstyles
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_simple_arrow_assets(self, arrowcolor: str, disabledcolor: str, activecolor: str, y_offset: int = 0):
        """
        Create simple arrow assets (small triangles) that can be used for various widgets.
        Originally created to replace Combobox.downarrow to fix layout issues in python 3.13.
        Also used for the Spinbox widget.

        Args:
            arrowcolor: The color value to use as the arrow fill color.
            disabledcolor: A second color value to use when the arrow is disabled.
            activecolor: A third color value to use when the arrow has focus.
            y_offset: (optional) The vertical padding to apply to the arrow images (useful in spinnboxes).
        Returns:
            A nested tuple containing the names of the created arrow images in the order (up, down, left, right)
            for each color.
        """

        def draw_simple_arrow(color: str, y_offset: int = 0):
            img = Image.new("RGBA", (13, 11))
            draw = ImageDraw.Draw(img)
            size = self.scale_size([13, 11])

            # Draw the arrow shape (triangle) pointing upwards, offset by the specified y_offset
            draw.polygon([(3, 6 + y_offset), (9, 6 + y_offset), (6, 3 + y_offset)], fill=color)

            img = img.resize(size, Resampling.BICUBIC)

            up_img = ImageTk.PhotoImage(img)
            up_name = util.get_image_name(up_img)
            self.theme_images[up_name] = up_img

            down_img = ImageTk.PhotoImage(img.rotate(180))
            down_name = util.get_image_name(down_img)
            self.theme_images[down_name] = down_img

            left_img = ImageTk.PhotoImage(img.rotate(90))
            left_name = util.get_image_name(left_img)
            self.theme_images[left_name] = left_img

            right_img = ImageTk.PhotoImage(img.rotate(-90))
            right_name = util.get_image_name(right_img)
            self.theme_images[right_name] = right_img

            return up_name, down_name, left_name, right_name

        normal_names = draw_simple_arrow(arrowcolor, y_offset=y_offset)
        pressed_names = draw_simple_arrow(disabledcolor, y_offset=y_offset)
        active_names = draw_simple_arrow(activecolor, y_offset=y_offset)

        return normal_names, pressed_names, active_names

    def create_arrow_assets(self, arrowcolor, pressed, active):
        """Create arrow assets used for various widget buttons.

        !!! note
            This method is currently not being utilized.

        Parameters:

            arrowcolor (str):
                The color value to use as the arrow fill color.

            pressed (str):
                The color value to use when the arrow is pressed.

            active (str):
                The color value to use when the arrow is active or
                hovered.
        """

        def draw_arrow(color: str):
            img = Image.new("RGBA", (11, 11))
            draw = ImageDraw.Draw(img)
            size = self.scale_size([11, 11])

            draw.line([2, 6, 2, 9], fill=color)
            draw.line([3, 5, 3, 8], fill=color)
            draw.line([4, 4, 4, 7], fill=color)
            draw.line([5, 3, 5, 6], fill=color)
            draw.line([6, 4, 6, 7], fill=color)
            draw.line([7, 5, 7, 8], fill=color)
            draw.line([8, 6, 8, 9], fill=color)

            img = img.resize(size, Resampling.BICUBIC)

            up_img = ImageTk.PhotoImage(img)
            up_name = util.get_image_name(up_img)
            self.theme_images[up_name] = up_img

            down_img = ImageTk.PhotoImage(img.rotate(180))
            down_name = util.get_image_name(down_img)
            self.theme_images[down_name] = down_img

            left_img = ImageTk.PhotoImage(img.rotate(90))
            left_name = util.get_image_name(left_img)
            self.theme_images[left_name] = left_img

            right_img = ImageTk.PhotoImage(img.rotate(-90))
            right_name = util.get_image_name(right_img)
            self.theme_images[right_name] = right_img

            return up_name, down_name, left_name, right_name

        normal_names = draw_arrow(arrowcolor)
        pressed_names = draw_arrow(pressed)
        active_names = draw_arrow(active)

        return normal_names, pressed_names, active_names

    def create_round_scrollbar_assets(self, thumbcolor, pressed, active):
        """Create image assets to be used when building the round
        scrollbar style.

        Parameters:

            thumbcolor (str):
                The color value of the thumb in normal state.

            pressed (str):
                The color value to use when the thumb is pressed.

            active (str):
                The color value to use when the thumb is active or
                hovered.
        """
        vsize = self.scale_size([9, 28])
        hsize = self.scale_size([28, 9])

        def rounded_rect(size, fill):
            x = size[0] * 10
            y = size[1] * 10
            img = Image.new("RGBA", (x, y))
            draw = ImageDraw.Draw(img)
            radius = min([x, y]) // 2
            draw.rounded_rectangle([0, 0, x - 1, y - 1], radius, fill)
            image = ImageTk.PhotoImage(img.resize(size, Resampling.BICUBIC))
            name = util.get_image_name(image)
            self.theme_images[name] = image
            return name

        # create images
        h_normal_img = rounded_rect(hsize, thumbcolor)
        h_pressed_img = rounded_rect(hsize, pressed)
        h_active_img = rounded_rect(hsize, active)

        v_normal_img = rounded_rect(vsize, thumbcolor)
        v_pressed_img = rounded_rect(vsize, pressed)
        v_active_img = rounded_rect(vsize, active)

        return (
            h_normal_img,
            h_pressed_img,
            h_active_img,
            v_normal_img,
            v_pressed_img,
            v_active_img,
        )

    def create_round_scrollbar_style(self, colorname=DEFAULT):
        """Create a round style for the ttk.Scrollbar widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TScrollbar"

        if any([colorname == DEFAULT, colorname == ""]):
            h_ttkstyle = f"Round.Horizontal.{STYLE}"
            v_ttkstyle = f"Round.Vertical.{STYLE}"

            if self.is_light_theme:
                background = self.colors.border
            else:
                background = self.colors.selectbg

        else:
            h_ttkstyle = f"{colorname}.Round.Horizontal.{STYLE}"
            v_ttkstyle = f"{colorname}.Round.Vertical.{STYLE}"
            background = self.colors.get(colorname)

        if self.is_light_theme:
            if colorname == LIGHT:
                troughcolor = self.colors.bg
            else:
                troughcolor = self.colors.light
        else:
            troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

        pressed = Colors.update_hsv(background, vd=-0.05)
        active = Colors.update_hsv(background, vd=0.05)

        scroll_images = self.create_round_scrollbar_assets(
            background, pressed, active
        )

        # horizontal scrollbar
        self.style._build_configure(
            h_ttkstyle,
            troughcolor=troughcolor,
            darkcolor=troughcolor,
            bordercolor=troughcolor,
            lightcolor=troughcolor,
            arrowcolor=background,
            arrowsize=self.scale_size(11),
            background=troughcolor,
            relief=tk.FLAT,
            borderwidth=0,
        )
        self.style.element_create(
            f"{h_ttkstyle}.thumb",
            "image",
            scroll_images[0],
            ("pressed", scroll_images[1]),
            ("active", scroll_images[2]),
            border=self.scale_size(9),
            padding=0,
            sticky=tk.EW,
        )
        self.style.layout(
            h_ttkstyle,
            [
                (
                    "Horizontal.Scrollbar.trough",
                    {
                        "sticky": "we",
                        "children": [
                            (
                                "Horizontal.Scrollbar.leftarrow",
                                {"side": "left", "sticky": ""},
                            ),
                            (
                                "Horizontal.Scrollbar.rightarrow",
                                {"side": "right", "sticky": ""},
                            ),
                            (
                                f"{h_ttkstyle}.thumb",
                                {"expand": "1", "sticky": "nswe"},
                            ),
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(h_ttkstyle, arrowcolor=background)
        self.style.map(
            h_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
        )

        # vertical scrollbar
        self.style._build_configure(
            v_ttkstyle,
            troughcolor=troughcolor,
            darkcolor=troughcolor,
            bordercolor=troughcolor,
            lightcolor=troughcolor,
            arrowcolor=background,
            arrowsize=self.scale_size(11),
            background=troughcolor,
            relief=tk.FLAT,
        )
        self.style.element_create(
            f"{v_ttkstyle}.thumb",
            "image",
            scroll_images[3],
            ("pressed", scroll_images[4]),
            ("active", scroll_images[5]),
            border=self.scale_size(9),
            padding=0,
            sticky=tk.NS,
        )
        self.style.layout(
            v_ttkstyle,
            [
                (
                    "Vertical.Scrollbar.trough",
                    {
                        "sticky": "ns",
                        "children": [
                            (
                                "Vertical.Scrollbar.uparrow",
                                {"side": "top", "sticky": ""},
                            ),
                            (
                                "Vertical.Scrollbar.downarrow",
                                {"side": "bottom", "sticky": ""},
                            ),
                            (
                                f"{v_ttkstyle}.thumb",
                                {"expand": "1", "sticky": "nswe"},
                            ),
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(v_ttkstyle, arrowcolor=background)
        self.style.map(
            v_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
        )

        # register ttkstyles
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_scrollbar_assets(self, thumbcolor, pressed, active):
        """Create the image assets used to build the standard scrollbar
        style.

        Parameters:

            thumbcolor (str):
                The primary color value used to color the thumb.

            pressed (str):
                The color value to use when the thumb is pressed.

            active (str):
                The color value to use when the thumb is active or
                hovered.
        """
        vsize = self.scale_size([9, 28])
        hsize = self.scale_size([28, 9])

        def draw_rect(size, fill):
            x = size[0] * 10
            y = size[1] * 10
            img = Image.new("RGBA", (x, y), fill)
            image = ImageTk.PhotoImage(img.resize(size), Resampling.BICUBIC)
            name = util.get_image_name(image)
            self.theme_images[name] = image
            return name

        # create images
        h_normal_img = draw_rect(hsize, thumbcolor)
        h_pressed_img = draw_rect(hsize, pressed)
        h_active_img = draw_rect(hsize, active)

        v_normal_img = draw_rect(vsize, thumbcolor)
        v_pressed_img = draw_rect(vsize, pressed)
        v_active_img = draw_rect(vsize, active)

        return (
            h_normal_img,
            h_pressed_img,
            h_active_img,
            v_normal_img,
            v_pressed_img,
            v_active_img,
        )

    def create_scrollbar_style(self, colorname=DEFAULT):
        """Create a standard style for the ttk.Scrollbar widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TScrollbar"

        if any([colorname == DEFAULT, colorname == ""]):
            h_ttkstyle = f"Horizontal.{STYLE}"
            v_ttkstyle = f"Vertical.{STYLE}"

            if self.is_light_theme:
                background = self.colors.border
            else:
                background = self.colors.selectbg

        else:
            h_ttkstyle = f"{colorname}.Horizontal.{STYLE}"
            v_ttkstyle = f"{colorname}.Vertical.{STYLE}"
            background = self.colors.get(colorname)

        if self.is_light_theme:
            if colorname == LIGHT:
                troughcolor = self.colors.bg
            else:
                troughcolor = self.colors.light
        else:
            troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

        pressed = Colors.update_hsv(background, vd=-0.05)
        active = Colors.update_hsv(background, vd=0.05)

        scroll_images = self.create_scrollbar_assets(
            background, pressed, active
        )

        # horizontal scrollbar
        self.style._build_configure(
            h_ttkstyle,
            troughcolor=troughcolor,
            darkcolor=troughcolor,
            bordercolor=troughcolor,
            lightcolor=troughcolor,
            arrowcolor=background,
            arrowsize=self.scale_size(11),
            background=troughcolor,
            relief=tk.FLAT,
            borderwidth=0,
        )
        self.style.element_create(
            f"{h_ttkstyle}.thumb",
            "image",
            scroll_images[0],
            ("pressed", scroll_images[1]),
            ("active", scroll_images[2]),
            border=(3, 0),
            sticky=tk.NSEW,
        )
        self.style.layout(
            h_ttkstyle,
            [
                (
                    "Horizontal.Scrollbar.trough",
                    {
                        "sticky": "we",
                        "children": [
                            (
                                "Horizontal.Scrollbar.leftarrow",
                                {"side": "left", "sticky": ""},
                            ),
                            (
                                "Horizontal.Scrollbar.rightarrow",
                                {"side": "right", "sticky": ""},
                            ),
                            (
                                f"{h_ttkstyle}.thumb",
                                {"expand": "1", "sticky": "nswe"},
                            ),
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(h_ttkstyle, arrowcolor=background)
        self.style.map(
            h_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
        )

        # vertical scrollbar
        self.style._build_configure(
            v_ttkstyle,
            troughcolor=troughcolor,
            darkcolor=troughcolor,
            bordercolor=troughcolor,
            lightcolor=troughcolor,
            arrowcolor=background,
            arrowsize=self.scale_size(11),
            background=troughcolor,
            relief=tk.FLAT,
            borderwidth=0,
        )
        self.style.element_create(
            f"{v_ttkstyle}.thumb",
            "image",
            scroll_images[3],
            ("pressed", scroll_images[4]),
            ("active", scroll_images[5]),
            border=(0, 3),
            sticky=tk.NSEW,
        )
        self.style.layout(
            v_ttkstyle,
            [
                (
                    "Vertical.Scrollbar.trough",
                    {
                        "sticky": "ns",
                        "children": [
                            (
                                "Vertical.Scrollbar.uparrow",
                                {"side": "top", "sticky": ""},
                            ),
                            (
                                "Vertical.Scrollbar.downarrow",
                                {"side": "bottom", "sticky": ""},
                            ),
                            (
                                f"{v_ttkstyle}.thumb",
                                {"expand": "1", "sticky": "nswe"},
                            ),
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(v_ttkstyle, arrowcolor=background)
        self.style.map(
            v_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
        )

        # register ttkstyles
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_spinbox_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Spinbox widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TSpinbox"

        if self.is_light_theme:
            disabled_fg = self.colors.border
            bordercolor = self.colors.border
            readonly = self.colors.light
        else:
            disabled_fg = self.colors.selectbg
            bordercolor = self.colors.selectbg
            readonly = bordercolor

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            focuscolor = self.colors.primary
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            focuscolor = self.colors.get(colorname)

        if all([colorname, colorname != DEFAULT]):
            bordercolor = focuscolor

        if colorname == "light":
            arrowfocus = self.colors.fg
        else:
            arrowfocus = focuscolor

        element = ttkstyle.replace(".TS", ".S")
        arrow_images = self.create_simple_arrow_assets(
            self.colors.inputfg, disabled_fg, arrowfocus, y_offset=2
        )
        uparrow_image = arrow_images[0][0]
        uparrow_disabled_image = arrow_images[1][0]
        uparrow_focus_image = arrow_images[2][0]
        downarrow_image = arrow_images[0][1]
        downarrow_disabled_image = arrow_images[1][1]
        downarrow_focus_image = arrow_images[2][1]

        self.style.element_create(
            f"{element}.uparrow",
            "image",
            uparrow_image,
            ("disabled", uparrow_disabled_image),
            ("pressed !disabled", uparrow_focus_image),
            ("hover !disabled", uparrow_focus_image),
        )
        self.style.element_create(
            f"{element}.downarrow",
            "image",
            downarrow_image,
            ("disabled", downarrow_disabled_image),
            ("pressed !disabled", downarrow_focus_image),
            ("hover !disabled", downarrow_focus_image),
        )
        self.style.layout(
            ttkstyle,
            [
                (
                    f"{element}.field",
                    {
                        "side": tk.TOP,
                        "sticky": tk.EW,
                        "children": [
                            (
                                "null",
                                {
                                    "side": tk.RIGHT,
                                    "sticky": "",
                                    "children": [
                                        (
                                            f"{element}.uparrow",
                                            {"side": tk.TOP, "sticky": tk.E},
                                        ),
                                        (
                                            f"{element}.downarrow",
                                            {
                                                "side": tk.BOTTOM,
                                                "sticky": tk.E,
                                            },
                                        ),
                                    ],
                                },
                            ),
                            (
                                f"{element}.padding",
                                {
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            f"{element}.textarea",
                                            {"sticky": tk.NSEW},
                                        )
                                    ],
                                },
                            ),
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(
            ttkstyle,
            bordercolor=bordercolor,
            darkcolor=self.colors.inputbg,
            lightcolor=self.colors.inputbg,
            fieldbackground=self.colors.inputbg,
            foreground=self.colors.inputfg,
            borderwidth=0,
            background=self.colors.inputbg,
            relief=tk.FLAT,
            insertcolor=self.colors.inputfg,
            padding=(10, 5),
        )
        self.style.map(
            ttkstyle,
            foreground=[("disabled", disabled_fg)],
            fieldbackground=[("readonly", readonly)],
            background=[("readonly", readonly)],
            lightcolor=[
                ("focus invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("readonly", readonly),
            ],
            darkcolor=[
                ("focus invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("readonly", readonly),
            ],
            bordercolor=[
                ("invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("hover !disabled", focuscolor),
            ],
        )
        # register ttkstyles
        self.style._register_ttkstyle(ttkstyle)

    def create_table_treeview_style(self, colorname=DEFAULT):
        """Create a style for the Tableview widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Table.Treeview"

        f = font.nametofont("TkDefaultFont")
        rowheight = f.metrics()["linespace"]

        if self.is_light_theme:
            disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.2)
            bordercolor = self.colors.border
            hover = Colors.update_hsv(self.colors.light, vd=-0.1)
        else:
            disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.3)
            bordercolor = self.colors.selectbg
            hover = Colors.update_hsv(self.colors.dark, vd=0.1)

        if any([colorname == DEFAULT, colorname == ""]):
            background = self.colors.inputbg
            foreground = self.colors.inputfg
            body_style = STYLE
            header_style = f"{STYLE}.Heading"
        elif colorname == LIGHT and self.is_light_theme:
            background = self.colors.get(colorname)
            foreground = self.colors.fg
            body_style = f"{colorname}.{STYLE}"
            header_style = f"{colorname}.{STYLE}.Heading"
            hover = Colors.update_hsv(background, vd=-0.1)
        else:
            background = self.colors.get(colorname)
            foreground = self.colors.selectfg
            body_style = f"{colorname}.{STYLE}"
            header_style = f"{colorname}.{STYLE}.Heading"
            hover = Colors.update_hsv(background, vd=0.1)

        # treeview header
        self.style._build_configure(
            header_style,
            background=background,
            foreground=foreground,
            relief=RAISED,
            borderwidth=1,
            darkcolor=background,
            bordercolor=bordercolor,
            lightcolor=background,
            padding=5,
        )
        self.style.map(
            header_style,
            foreground=[("disabled", disabled_fg)],
            background=[
                ("active !disabled", hover),
            ],
            darkcolor=[
                ("active !disabled", hover),
            ],
            lightcolor=[
                ("active !disabled", hover),
            ],
        )
        self.style._build_configure(
            body_style,
            background=self.colors.inputbg,
            fieldbackground=self.colors.inputbg,
            foreground=self.colors.inputfg,
            bordercolor=bordercolor,
            lightcolor=self.colors.inputbg,
            darkcolor=self.colors.inputbg,
            borderwidth=2,
            padding=0,
            rowheight=rowheight,
            relief=tk.RAISED,
        )
        self.style.map(
            body_style,
            background=[("selected", self.colors.selectbg)],
            foreground=[
                ("disabled", disabled_fg),
                ("selected", self.colors.selectfg),
            ],
        )
        self.style.layout(
            body_style,
            [
                (
                    "Button.border",
                    {
                        "sticky": tk.NSEW,
                        "border": "1",
                        "children": [
                            (
                                "Treeview.padding",
                                {
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            "Treeview.treearea",
                                            {"sticky": tk.NSEW},
                                        )
                                    ],
                                },
                            )
                        ],
                    },
                )
            ],
        )
        # register ttkstyles
        self.style._register_ttkstyle(body_style)

    def create_treeview_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Treeview widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Treeview"

        f = font.nametofont("TkDefaultFont")
        rowheight = f.metrics()["linespace"]

        if self.is_light_theme:
            disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.2)
            bordercolor = self.colors.border
        else:
            disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.3)
            bordercolor = self.colors.selectbg

        if any([colorname == DEFAULT, colorname == ""]):
            background = self.colors.inputbg
            foreground = self.colors.inputfg
            body_style = STYLE
            header_style = f"{STYLE}.Heading"
            focuscolor = self.colors.primary
        elif colorname == LIGHT and self.is_light_theme:
            background = self.colors.get(colorname)
            foreground = self.colors.fg
            body_style = f"{colorname}.{STYLE}"
            header_style = f"{colorname}.{STYLE}.Heading"
            focuscolor = background
            bordercolor = focuscolor
        else:
            background = self.colors.get(colorname)
            foreground = self.colors.selectfg
            body_style = f"{colorname}.{STYLE}"
            header_style = f"{colorname}.{STYLE}.Heading"
            focuscolor = background
            bordercolor = focuscolor

        # treeview header
        self.style._build_configure(
            header_style,
            background=background,
            foreground=foreground,
            relief=tk.FLAT,
            padding=5,
        )
        self.style.map(
            header_style,
            foreground=[("disabled", disabled_fg)],
            bordercolor=[("focus !disabled", background)],
        )
        # treeview body
        self.style._build_configure(
            body_style,
            background=self.colors.inputbg,
            fieldbackground=self.colors.inputbg,
            foreground=self.colors.inputfg,
            bordercolor=bordercolor,
            lightcolor=self.colors.inputbg,
            darkcolor=self.colors.inputbg,
            borderwidth=2,
            padding=0,
            rowheight=rowheight,
            relief=tk.RAISED,
        )
        self.style.map(
            body_style,
            background=[("selected", self.colors.selectbg)],
            foreground=[
                ("disabled", disabled_fg),
                ("selected", self.colors.selectfg),
            ],
            bordercolor=[
                ("disabled", bordercolor),
                ("focus", focuscolor),
                ("pressed", focuscolor),
                ("hover", focuscolor),
            ],
            lightcolor=[("focus", focuscolor)],
            darkcolor=[("focus", focuscolor)],
        )
        self.style.layout(
            body_style,
            [
                (
                    "Button.border",
                    {
                        "sticky": tk.NSEW,
                        "border": "1",
                        "children": [
                            (
                                "Treeview.padding",
                                {
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            "Treeview.treearea",
                                            {"sticky": tk.NSEW},
                                        )
                                    ],
                                },
                            )
                        ],
                    },
                )
            ],
        )

        try:
            self.style.element_create("Treeitem.indicator", "from", TTK_ALT)
        except:
            pass

        # register ttkstyles
        self.style._register_ttkstyle(body_style)

    def create_frame_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Frame widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TFrame"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            background = self.colors.bg
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            background = self.colors.get(colorname)

        self.style._build_configure(ttkstyle, background=background)

        # register style
        self.style._register_ttkstyle(ttkstyle)

    def create_button_style(self, colorname=DEFAULT):
        """Create a solid style for the ttk.Button widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TButton"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            foreground = self.colors.get_foreground(PRIMARY)
            background = self.colors.primary
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            foreground = self.colors.get_foreground(colorname)
            background = self.colors.get(colorname)

        bordercolor = background
        disabled_bg = Colors.make_transparent(0.10, self.colors.fg, self.colors.bg)
        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)
        pressed = Colors.make_transparent(0.80, background, self.colors.bg)
        hover = Colors.make_transparent(0.90, background, self.colors.bg)

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=background,
            bordercolor=bordercolor,
            darkcolor=background,
            lightcolor=background,
            relief=tk.RAISED,
            focusthickness=1,
            focuscolor=foreground,
            padding=(10, 5),
            anchor=tk.CENTER,
        )
        self.style.map(
            ttkstyle,
            foreground=[("disabled", disabled_fg)],
            focuscolor=[("disabled", disabled_fg)],
            background=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            bordercolor=[("disabled", disabled_bg)],
            darkcolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            lightcolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_outline_button_style(self, colorname=DEFAULT):
        """Create an outline style for the ttk.Button widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Outline.TButton"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            colorname = PRIMARY
        else:
            ttkstyle = f"{colorname}.{STYLE}"

        foreground = self.colors.get(colorname)
        background = self.colors.get_foreground(colorname)
        foreground_pressed = background
        bordercolor = foreground
        pressed = foreground
        hover = foreground

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=self.colors.bg,
            bordercolor=bordercolor,
            darkcolor=self.colors.bg,
            lightcolor=self.colors.bg,
            relief=tk.RAISED,
            focusthickness=1,
            focuscolor=foreground,
            padding=(10, 5),
            anchor=tk.CENTER,
        )
        self.style.map(
            ttkstyle,
            foreground=[
                ("disabled", disabled_fg),
                ("pressed !disabled", foreground_pressed),
                ("hover !disabled", foreground_pressed),
            ],
            background=[
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            bordercolor=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            focuscolor=[
                ("pressed !disabled", foreground_pressed),
                ("hover !disabled", foreground_pressed),
            ],
            darkcolor=[
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            lightcolor=[
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_link_button_style(self, colorname=DEFAULT):
        """Create a link button style for the ttk.Button widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Link.TButton"

        pressed = self.colors.info
        hover = self.colors.info

        if any([colorname == DEFAULT, colorname == ""]):
            foreground = self.colors.fg
            ttkstyle = STYLE
        elif colorname == LIGHT:
            foreground = self.colors.fg
            ttkstyle = f"{colorname}.{STYLE}"
        else:
            foreground = self.colors.get(colorname)
            ttkstyle = f"{colorname}.{STYLE}"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=self.colors.bg,
            bordercolor=self.colors.bg,
            darkcolor=self.colors.bg,
            lightcolor=self.colors.bg,
            relief=tk.RAISED,
            focusthickness=1,
            focuscolor=foreground,
            anchor=tk.CENTER,
            padding=(10, 5),
        )
        self.style.map(
            ttkstyle,
            shiftrelief=[("pressed !disabled", -1)],
            foreground=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            focuscolor=[
                ("pressed !disabled", pressed),
                ("hover !disabled", pressed),
            ],
            background=[
                ("disabled", self.colors.bg),
                ("pressed !disabled", self.colors.bg),
                ("hover !disabled", self.colors.bg),
            ],
            bordercolor=[
                ("disabled", self.colors.bg),
                ("pressed !disabled", self.colors.bg),
                ("hover !disabled", self.colors.bg),
            ],
            darkcolor=[
                ("disabled", self.colors.bg),
                ("pressed !disabled", self.colors.bg),
                ("hover !disabled", self.colors.bg),
            ],
            lightcolor=[
                ("disabled", self.colors.bg),
                ("pressed !disabled", self.colors.bg),
                ("hover !disabled", self.colors.bg),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_square_toggle_assets(self, colorname=DEFAULT):
        """Create the image assets used to build a square toggle
        style.

        Parameters:

            colorname (str):
                The color label used to style the widget.

        Returns:

            tuple[str]:
                A tuple of PhotoImage names.
        """
        size = self.scale_size([24, 15])
        if any([colorname == DEFAULT, colorname == ""]):
            colorname = PRIMARY

        # set default style color values
        prime_color = self.colors.get(colorname)
        on_border = prime_color
        on_indicator = self.colors.selectfg
        on_fill = prime_color
        off_fill = self.colors.bg
        disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)
        off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
        off_indicator = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)

        # override defaults for light and dark colors
        if colorname == LIGHT:
            on_border = self.colors.dark
            on_indicator = on_border
        elif colorname == DARK:
            on_border = self.colors.light
            on_indicator = on_border

        # toggle off
        _off = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(_off)
        draw.rectangle(
            xy=[1, 1, 225, 129], outline=off_border, width=6, fill=off_fill
        )
        draw.rectangle([18, 18, 110, 110], fill=off_indicator)

        off_img = ImageTk.PhotoImage(_off.resize(size, Resampling.LANCZOS))
        off_name = util.get_image_name(off_img)
        self.theme_images[off_name] = off_img

        # toggle on
        toggle_on = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(toggle_on)
        draw.rectangle(
            xy=[1, 1, 225, 129], outline=on_border, width=6, fill=on_fill
        )
        draw.rectangle([18, 18, 110, 110], fill=on_indicator)
        _on = toggle_on.transpose(Transpose.ROTATE_180)
        on_img = ImageTk.PhotoImage(_on.resize(size, Resampling.LANCZOS))
        on_name = util.get_image_name(on_img)
        self.theme_images[on_name] = on_img

        # toggle disabled
        _disabled = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(_disabled)
        draw.rectangle([1, 1, 225, 129], outline=disabled_fg, width=6)
        draw.rectangle([18, 18, 110, 110], fill=disabled_fg)
        disabled_img = ImageTk.PhotoImage(
            _disabled.resize(size, Resampling.LANCZOS)
        )
        disabled_name = util.get_image_name(disabled_img)
        self.theme_images[disabled_name] = disabled_img

        # toggle on / disabled
        toggle_on_disabled = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(toggle_on_disabled)
        draw.rectangle(
            xy=[1, 1, 225, 129], outline=disabled_fg, width=6, fill=off_fill
        )
        draw.rectangle([18, 18, 110, 110], fill=disabled_fg)
        _on_disabled = toggle_on_disabled.transpose(Transpose.ROTATE_180)
        on_dis_img = ImageTk.PhotoImage(_on_disabled.resize(size, Resampling.LANCZOS))
        on_disabled_name = util.get_image_name(on_dis_img)
        self.theme_images[on_disabled_name] = on_dis_img

        return off_name, on_name, disabled_name, on_disabled_name

    def create_toggle_style(self, colorname=DEFAULT):
        """Create a round toggle style for the ttk.Checkbutton widget.

        Parameters:

            colorname (str):
        """
        self.create_round_toggle_style(colorname)

    def create_round_toggle_assets(self, colorname=DEFAULT):
        """Create image assets for the round toggle style.

        Parameters:

            colorname (str):
                The color label assigned to the colors property.

        Returns:

            tuple[str]:
                A tuple of PhotoImage names.
        """
        size = self.scale_size([24, 15])

        if any([colorname == DEFAULT, colorname == ""]):
            colorname = PRIMARY

        # set default style color values
        prime_color = self.colors.get(colorname)
        on_border = prime_color
        on_indicator = self.colors.selectfg
        on_fill = prime_color
        off_fill = self.colors.bg

        disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)
        off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
        off_indicator = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)

        # override defaults for light and dark colors
        if colorname == LIGHT:
            on_border = self.colors.dark
            on_indicator = on_border
        elif colorname == DARK:
            on_border = self.colors.light
            on_indicator = on_border

        # toggle off
        _off = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(_off)
        draw.rounded_rectangle(
            xy=[1, 1, 225, 129],
            radius=(128 / 2),
            outline=off_border,
            width=6,
            fill=off_fill,
        )
        draw.ellipse([20, 18, 112, 110], fill=off_indicator)
        off_img = ImageTk.PhotoImage(_off.resize(size, Resampling.LANCZOS))
        off_name = util.get_image_name(off_img)
        self.theme_images[off_name] = off_img

        # toggle on
        _on = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(_on)
        draw.rounded_rectangle(
            xy=[1, 1, 225, 129],
            radius=(128 / 2),
            outline=on_border,
            width=6,
            fill=on_fill,
        )
        draw.ellipse([20, 18, 112, 110], fill=on_indicator)
        _on = _on.transpose(Transpose.ROTATE_180)
        on_img = ImageTk.PhotoImage(_on.resize(size, Resampling.LANCZOS))
        on_name = util.get_image_name(on_img)
        self.theme_images[on_name] = on_img

        # toggle on / disabled
        _on_disabled = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(_on_disabled)
        draw.rounded_rectangle(
            xy=[1, 1, 225, 129],
            radius=(128 / 2),
            outline=disabled_fg,
            width=6,
            fill=off_fill,
        )
        draw.ellipse([20, 18, 112, 110], fill=disabled_fg)
        _on_disabled = _on_disabled.transpose(Transpose.ROTATE_180)
        on_dis_img = ImageTk.PhotoImage(_on_disabled.resize(size, Resampling.LANCZOS))
        on_disabled_name = util.get_image_name(on_dis_img)
        self.theme_images[on_disabled_name] = on_dis_img

        # toggle disabled
        _disabled = Image.new("RGBA", (226, 130))
        draw = ImageDraw.Draw(_disabled)
        draw.rounded_rectangle(
            xy=[1, 1, 225, 129], radius=(128 / 2), outline=disabled_fg, width=6
        )
        draw.ellipse([20, 18, 112, 110], fill=disabled_fg)
        disabled_img = ImageTk.PhotoImage(
            _disabled.resize(size, Resampling.LANCZOS)
        )
        disabled_name = util.get_image_name(disabled_img)
        self.theme_images[disabled_name] = disabled_img

        return off_name, on_name, disabled_name, on_disabled_name

    def create_round_toggle_style(self, colorname=DEFAULT):
        """Create a round toggle style for the ttk.Checkbutton widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Round.Toggle"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            colorname = PRIMARY
        else:
            ttkstyle = f"{colorname}.{STYLE}"

        # ( off, on, disabled )
        images = self.create_round_toggle_assets(colorname)

        try:
            width = self.scale_size(28)
            borderpad = self.scale_size(4)
            self.style.element_create(
                f"{ttkstyle}.indicator",
                "image",
                images[1],
                ("disabled selected", images[3]),
                ("disabled", images[2]),
                ("!selected", images[0]),
                width=width,
                border=borderpad,
                sticky=tk.W,
            )
        except:
            """This method is used as the default Toggle style, so it
            is neccessary to catch Tcl Errors when it tries to create
            and element that was already created by the Toggle or
            Round Toggle style"""
            pass

        self.style._build_configure(
            ttkstyle,
            relief=tk.FLAT,
            borderwidth=0,
            padding=0,
            foreground=self.colors.fg,
            background=self.colors.bg,
        )
        self.style.map(
            ttkstyle,
            foreground=[("disabled", disabled_fg)],
            background=[("selected", self.colors.bg)],
        )
        self.style.layout(
            ttkstyle,
            [
                (
                    "Toolbutton.border",
                    {
                        "sticky": tk.NSEW,
                        "children": [
                            (
                                "Toolbutton.padding",
                                {
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            f"{ttkstyle}.indicator",
                                            {"side": tk.LEFT},
                                        ),
                                        (
                                            "Toolbutton.label",
                                            {"side": tk.LEFT},
                                        ),
                                    ],
                                },
                            )
                        ],
                    },
                )
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_square_toggle_style(self, colorname=DEFAULT):
        """Create a square toggle style for the ttk.Checkbutton widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """

        STYLE = "Square.Toggle"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
        else:
            ttkstyle = f"{colorname}.{STYLE}"

        # ( off, on, disabled )
        images = self.create_square_toggle_assets(colorname)

        width = self.scale_size(28)
        borderpad = self.scale_size(4)

        self.style.element_create(
            f"{ttkstyle}.indicator",
            "image",
            images[1],
            ("disabled selected", images[3]),
            ("disabled", images[2]),
            ("!selected", images[0]),
            width=width,
            border=borderpad,
            sticky=tk.W,
        )
        self.style.layout(
            ttkstyle,
            [
                (
                    "Toolbutton.border",
                    {
                        "sticky": tk.NSEW,
                        "children": [
                            (
                                "Toolbutton.padding",
                                {
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            f"{ttkstyle}.indicator",
                                            {"side": tk.LEFT},
                                        ),
                                        (
                                            "Toolbutton.label",
                                            {"side": tk.LEFT},
                                        ),
                                    ],
                                },
                            )
                        ],
                    },
                )
            ],
        )
        self.style._build_configure(
            ttkstyle, relief=tk.FLAT, borderwidth=0, foreground=self.colors.fg
        )
        self.style.map(
            ttkstyle,
            foreground=[("disabled", disabled_fg)],
            background=[
                ("selected", self.colors.bg),
                ("!selected", self.colors.bg),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_toolbutton_style(self, colorname=DEFAULT):
        """Create a solid toolbutton style for the ttk.Checkbutton
        and ttk.Radiobutton widgets.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Toolbutton"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            toggle_on = self.colors.primary
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            toggle_on = self.colors.get(colorname)

        foreground = self.colors.get_foreground(colorname)

        if self.is_light_theme:
            toggle_off = self.colors.border
        else:
            toggle_off = self.colors.selectbg

        disabled_bg = Colors.make_transparent(0.10, self.colors.fg, self.colors.bg)
        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        self.style._build_configure(
            ttkstyle,
            foreground=self.colors.selectfg,
            background=toggle_off,
            bordercolor=toggle_off,
            darkcolor=toggle_off,
            lightcolor=toggle_off,
            relief=tk.RAISED,
            focusthickness=1,
            focuscolor=foreground,
            padding=(10, 5),
            anchor=tk.CENTER,
        )
        self.style.map(
            ttkstyle,
            foreground=[
                ("disabled", disabled_fg),
                ("hover", foreground),
                ("selected", foreground),
            ],
            focuscolor=[
                ("disabled", disabled_fg),
                ("hover", foreground),
                ("selected", foreground),
            ],
            background=[
                ("disabled", disabled_bg),
                ("pressed !disabled", toggle_on),
                ("selected !disabled", toggle_on),
                ("hover !disabled", toggle_on),
            ],
            bordercolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", toggle_on),
                ("selected !disabled", toggle_on),
                ("hover !disabled", toggle_on),
            ],
            darkcolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", toggle_on),
                ("selected !disabled", toggle_on),
                ("hover !disabled", toggle_on),
            ],
            lightcolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", toggle_on),
                ("selected !disabled", toggle_on),
                ("hover !disabled", toggle_on),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_outline_toolbutton_style(self, colorname=DEFAULT):
        """Create an outline toolbutton style for the ttk.Checkbutton
        and ttk.Radiobutton widgets.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Outline.Toolbutton"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            colorname = PRIMARY
        else:
            ttkstyle = f"{colorname}.{STYLE}"

        foreground = self.colors.get(colorname)
        background = self.colors.get_foreground(colorname)
        foreground_pressed = background
        bordercolor = foreground
        pressed = foreground
        hover = foreground

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=self.colors.bg,
            bordercolor=bordercolor,
            darkcolor=self.colors.bg,
            lightcolor=self.colors.bg,
            relief=tk.RAISED,
            focusthickness=0,
            focuscolor=foreground,
            padding=(10, 5),
            anchor=tk.CENTER,
            arrowcolor=foreground,
            arrowpadding=(0, 0, 15, 0),
            arrowsize=3,
        )
        self.style.map(
            ttkstyle,
            foreground=[
                ("disabled", disabled_fg),
                ("pressed !disabled", foreground_pressed),
                ("selected !disabled", foreground_pressed),
                ("hover !disabled", foreground_pressed),
            ],
            background=[
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", hover),
            ],
            bordercolor=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", hover),
            ],
            darkcolor=[
                ("disabled", self.colors.bg),
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", hover),
            ],
            lightcolor=[
                ("disabled", self.colors.bg),
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", hover),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_entry_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Entry widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TEntry"

        # general default colors
        if self.is_light_theme:
            disabled_fg = self.colors.border
            bordercolor = self.colors.border
            readonly = self.colors.light
        else:
            disabled_fg = self.colors.selectbg
            bordercolor = self.colors.selectbg
            readonly = bordercolor

        if any([colorname == DEFAULT, not colorname]):
            # default style
            ttkstyle = STYLE
            focuscolor = self.colors.primary
        else:
            # colored style
            ttkstyle = f"{colorname}.{STYLE}"
            focuscolor = self.colors.get(colorname)
            bordercolor = focuscolor

        self.style._build_configure(
            ttkstyle,
            bordercolor=bordercolor,
            darkcolor=self.colors.inputbg,
            lightcolor=self.colors.inputbg,
            fieldbackground=self.colors.inputbg,
            foreground=self.colors.inputfg,
            insertcolor=self.colors.inputfg,
            padding=5,
        )
        self.style.map(
            ttkstyle,
            foreground=[("disabled", disabled_fg)],
            fieldbackground=[("readonly", readonly)],
            bordercolor=[
                ("invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("hover !disabled", focuscolor),
            ],
            lightcolor=[
                ("focus invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("readonly", readonly),
            ],
            darkcolor=[
                ("focus invalid", self.colors.danger),
                ("focus !disabled", focuscolor),
                ("readonly", readonly),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_radiobutton_assets(self, colorname=DEFAULT):
        """Create the image assets used to build the radiobutton style.

        Parameters:

            colorname (str):

        Returns:

            tuple[str]:
                A tuple of PhotoImage names
        """
        prime_color = self.colors.get(colorname)
        on_fill = prime_color
        off_fill = self.colors.bg
        on_indicator = self.colors.selectfg
        size = self.scale_size([14, 14])
        off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
        disabled = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)

        if self.is_light_theme:
            if colorname == LIGHT:
                on_indicator = self.colors.dark

        # radio off
        _off = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(_off)
        draw.ellipse(
            xy=[1, 1, 133, 133], outline=off_border, width=6, fill=off_fill
        )
        off_img = ImageTk.PhotoImage(_off.resize(size, Resampling.LANCZOS))
        off_name = util.get_image_name(off_img)
        self.theme_images[off_name] = off_img

        # radio on
        _on = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(_on)
        if colorname == LIGHT and self.is_light_theme:
            draw.ellipse(xy=[1, 1, 133, 133], outline=off_border, width=6)
        else:
            draw.ellipse(xy=[1, 1, 133, 133], fill=on_fill)
        draw.ellipse([40, 40, 94, 94], fill=on_indicator)
        on_img = ImageTk.PhotoImage(_on.resize(size, Resampling.LANCZOS))
        on_name = util.get_image_name(on_img)
        self.theme_images[on_name] = on_img

        # radio on/disabled
        _on_dis = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(_on_dis)
        if colorname == LIGHT and self.is_light_theme:
            draw.ellipse(xy=[1, 1, 133, 133], outline=off_border, width=6)
        else:
            draw.ellipse(xy=[1, 1, 133, 133], fill=disabled)
        draw.ellipse([40, 40, 94, 94], fill=off_fill)
        on_dis_img = ImageTk.PhotoImage(_on_dis.resize(size, Resampling.LANCZOS))
        on_disabled_name = util.get_image_name(on_dis_img)
        self.theme_images[on_disabled_name] = on_dis_img

        # radio disabled
        _disabled = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(_disabled)
        draw.ellipse(
            xy=[1, 1, 133, 133], outline=disabled, width=3, fill=off_fill
        )
        disabled_img = ImageTk.PhotoImage(
            _disabled.resize(size, Resampling.LANCZOS)
        )
        disabled_name = util.get_image_name(disabled_img)
        self.theme_images[disabled_name] = disabled_img

        return off_name, on_name, disabled_name, on_disabled_name

    def create_radiobutton_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Radiobutton widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """

        STYLE = "TRadiobutton"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            colorname = PRIMARY
        else:
            ttkstyle = f"{colorname}.{STYLE}"

        # ( off, on, disabled )
        images = self.create_radiobutton_assets(colorname)
        width = self.scale_size(20)
        borderpad = self.scale_size(4)
        self.style.element_create(
            f"{ttkstyle}.indicator",
            "image",
            images[1],
            ("disabled selected", images[3]),
            ("disabled", images[2]),
            ("!selected", images[0]),
            width=width,
            border=borderpad,
            sticky=tk.W,
        )
        self.style.map(ttkstyle, foreground=[("disabled", disabled_fg)])
        self.style._build_configure(ttkstyle)
        self.style.layout(
            ttkstyle,
            [
                (
                    "Radiobutton.padding",
                    {
                        "children": [
                            (
                                f"{ttkstyle}.indicator",
                                {"side": tk.LEFT, "sticky": ""},
                            ),
                            (
                                "Radiobutton.focus",
                                {
                                    "children": [
                                        (
                                            "Radiobutton.label",
                                            {"sticky": tk.NSEW},
                                        )
                                    ],
                                    "side": tk.LEFT,
                                    "sticky": "",
                                },
                            ),
                        ],
                        "sticky": tk.NSEW,
                    },
                )
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_date_button_assets(self, foreground):
        """Create the image assets used to build the date button
        style. This button style applied to the button in the
        ttkbootstrap.widgets.DateEntry.

        Parameters:

            foreground (str):
                The color value used to draw the calendar image.

        Returns:

            str:
                The PhotoImage name.
        """
        fill = foreground
        image = Image.new("RGBA", (210, 220))
        draw = ImageDraw.Draw(image)

        draw.rounded_rectangle(
            [10, 30, 200, 210], radius=20, outline=fill, width=10
        )

        calendar_image_coordinates = [
            # page spirals
            [40, 10, 50, 50],
            [100, 10, 110, 50],
            [160, 10, 170, 50],
            # row 1
            [70, 90, 90, 110],
            [110, 90, 130, 110],
            [150, 90, 170, 110],
            # row 2
            [30, 130, 50, 150],
            [70, 130, 90, 150],
            [110, 130, 130, 150],
            [150, 130, 170, 150],
            # row 3
            [30, 170, 50, 190],
            [70, 170, 90, 190],
            [110, 170, 130, 190],
        ]
        for xy in calendar_image_coordinates:
            draw.rectangle(xy=xy, fill=fill)

        size = self.scale_size([21, 22])
        tk_img = ImageTk.PhotoImage(image.resize(size, Resampling.LANCZOS))
        tk_name = util.get_image_name(tk_img)
        self.theme_images[tk_name] = tk_img
        return tk_name

    def create_date_button_style(self, colorname=DEFAULT):
        """Create a date button style for the ttk.Button widget.

        Parameters:

            colorname (str):
                The color label used to style widget.
        """
        STYLE = "Date.TButton"

        if self.is_light_theme:
            disabled_fg = self.colors.border
        else:
            disabled_fg = self.colors.selectbg

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            foreground = self.colors.get_foreground(PRIMARY)
            background = self.colors.primary
            btn_foreground = Colors.get_foreground(self.colors, PRIMARY)
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            foreground = self.colors.get_foreground(colorname)
            background = self.colors.get(colorname)
            btn_foreground = Colors.get_foreground(self.colors, colorname)

        img_normal = self.create_date_button_assets(btn_foreground)

        pressed = Colors.update_hsv(background, vd=-0.1)
        hover = Colors.update_hsv(background, vd=0.10)

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=background,
            bordercolor=background,
            darkcolor=background,
            lightcolor=background,
            relief=tk.RAISED,
            focusthickness=0,
            focuscolor=foreground,
            padding=(2, 2),
            anchor=tk.CENTER,
            image=img_normal,
        )
        self.style.map(
            ttkstyle,
            foreground=[("disabled", disabled_fg)],
            background=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            bordercolor=[("disabled", disabled_fg)],
            darkcolor=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            lightcolor=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
        )

        self.style._register_ttkstyle(ttkstyle)

    def create_calendar_style(self, colorname=DEFAULT):
        """Create a style for the
        ttkbootstrap.dialogs.DatePickerPopup widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """

        STYLE = "TCalendar"

        if any([colorname == DEFAULT, colorname == ""]):
            prime_color = self.colors.primary
            ttkstyle = STYLE
            chevron_style = "Chevron.TButton"
        else:
            prime_color = self.colors.get(colorname)
            ttkstyle = f"{colorname}.{STYLE}"
            chevron_style = f"Chevron.{colorname}.TButton"

        if self.is_light_theme:
            disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.2)
            pressed = Colors.update_hsv(prime_color, vd=-0.1)
        else:
            disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.3)
            pressed = Colors.update_hsv(prime_color, vd=0.1)

        self.style._build_configure(
            ttkstyle,
            foreground=self.colors.fg,
            background=self.colors.bg,
            bordercolor=self.colors.bg,
            darkcolor=self.colors.bg,
            lightcolor=self.colors.bg,
            relief=tk.RAISED,
            focusthickness=1,
            focuscolor=self.colors.fg,
            borderwidth=1,
            padding=(10, 5),
            anchor=tk.CENTER,
        )
        self.style.layout(
            ttkstyle,
            [
                (
                    "Toolbutton.border",
                    {
                        "sticky": tk.NSEW,
                        "children": [
                            (
                                "Toolbutton.focus",
                                {
                                    "sticky": tk.NSEW,
                                    "children": [
                                        (
                                            "Toolbutton.padding",
                                            {
                                                "sticky": tk.NSEW,
                                                "children": [
                                                    ("Toolbutton.label", {"sticky": tk.NSEW})
                                                ],
                                            },
                                        )
                                    ],
                                },
                            )
                        ],
                    },
                )
            ],
        )

        self.style.map(
            ttkstyle,
            foreground=[
                ("disabled", disabled_fg),
                ("pressed !disabled", self.colors.selectfg),
                ("selected !disabled", self.colors.selectfg),
                ("hover !disabled", self.colors.selectfg),
            ],
            background=[
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", pressed),
            ],
            bordercolor=[
                ("disabled", disabled_fg),
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", pressed),
            ],
            darkcolor=[
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", pressed),
            ],
            lightcolor=[
                ("pressed !disabled", pressed),
                ("selected !disabled", pressed),
                ("hover !disabled", pressed),
            ],
            focuscolor=[
                ("disabled", disabled_fg),
                ("pressed !disabled", self.colors.selectfg),
                ("selected !disabled", self.colors.selectfg),
                ("hover !disabled", self.colors.selectfg),
            ]
        )
        self.style._build_configure(chevron_style, font="-size 14")

        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)
        self.style._register_ttkstyle(chevron_style)

    def create_metersubtxt_label_style(self, colorname=DEFAULT):
        """Create a subtext label style for the
        ttkbootstrap.widgets.Meter widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Metersubtxt.TLabel"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            if self.is_light_theme:
                foreground = self.colors.secondary
            else:
                foreground = self.colors.light
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            foreground = self.colors.get(colorname)

        background = self.colors.bg

        self.style._build_configure(
            ttkstyle, foreground=foreground, background=background
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_meter_label_style(self, colorname=DEFAULT):
        """Create a label style for the
        ttkbootstrap.widgets.Meter widget. This style also stores some
        metadata that is called by the Meter class to lookup relevant
        colors for the trough and bar when the new image is drawn.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """

        STYLE = "Meter.TLabel"

        # text color = `foreground`
        # trough color = `space`

        if self.is_light_theme:
            if colorname == LIGHT:
                troughcolor = self.colors.bg
            else:
                troughcolor = self.colors.light
        else:
            troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            background = self.colors.bg
            textcolor = self.colors.primary
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            textcolor = self.colors.get(colorname)
            background = self.colors.bg

        self.style._build_configure(
            ttkstyle,
            foreground=textcolor,
            background=background,
            space=troughcolor,
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_label_style(self, colorname=DEFAULT):
        """Create a standard style for the ttk.Label widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TLabel"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            foreground = self.colors.fg
            background = self.colors.bg
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            foreground = self.colors.get(colorname)
            background = self.colors.bg

        # standard label
        self.style._build_configure(
            ttkstyle, foreground=foreground, background=background
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_inverse_label_style(self, colorname=DEFAULT):
        """Create an inverted style for the ttk.Label.

        The foreground and background are inverted versions of that
        used in the standard label style.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE_INVERSE = "Inverse.TLabel"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE_INVERSE
            background = self.colors.fg
            foreground = self.colors.bg
        else:
            ttkstyle = f"{colorname}.{STYLE_INVERSE}"
            background = self.colors.get(colorname)
            foreground = self.colors.get_foreground(colorname)

        self.style._build_configure(
            ttkstyle, foreground=foreground, background=background
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_labelframe_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Labelframe widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TLabelframe"

        background = self.colors.bg

        if any([colorname == DEFAULT, colorname == ""]):
            foreground = self.colors.fg
            ttkstyle = STYLE

            if self.is_light_theme:
                bordercolor = self.colors.border
            else:
                bordercolor = self.colors.selectbg

        else:
            foreground = self.colors.get(colorname)
            bordercolor = foreground
            ttkstyle = f"{colorname}.{STYLE}"

        # create widget style
        self.style._build_configure(
            f"{ttkstyle}.Label",
            foreground=foreground,
            background=background,
        )
        self.style._build_configure(
            ttkstyle,
            relief=tk.RAISED,
            borderwidth=1,
            bordercolor=bordercolor,
            lightcolor=background,
            darkcolor=background,
            background=background,
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_checkbutton_style(self, colorname=DEFAULT):
        """Create a standard style for the ttk.Checkbutton widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TCheckbutton"

        disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            colorname = PRIMARY
            ttkstyle = STYLE
        else:
            ttkstyle = f"{colorname}.TCheckbutton"

        # ( off, on, disabled )
        images = self.create_checkbutton_assets(colorname)

        element = ttkstyle.replace(".TC", ".C")
        width = self.scale_size(20)
        borderpad = self.scale_size(4)
        self.style.element_create(
            f"{element}.indicator",
            "image",
            images[1],
            ("disabled selected", images[4]),
            ("disabled alternate", images[5]),
            ("disabled", images[2]),
            ("alternate", images[3]),
            ("!selected", images[0]),
            width=width,
            border=borderpad,
            sticky=tk.W,
        )
        self.style._build_configure(ttkstyle, foreground=self.colors.fg)
        self.style.map(ttkstyle, foreground=[("disabled", disabled_fg)])
        self.style.layout(
            ttkstyle,
            [
                (
                    "Checkbutton.padding",
                    {
                        "children": [
                            (
                                f"{element}.indicator",
                                {"side": tk.LEFT, "sticky": ""},
                            ),
                            (
                                "Checkbutton.focus",
                                {
                                    "children": [
                                        (
                                            "Checkbutton.label",
                                            {"sticky": tk.NSEW},
                                        )
                                    ],
                                    "side": tk.LEFT,
                                    "sticky": "",
                                },
                            ),
                        ],
                        "sticky": tk.NSEW,
                    },
                )
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_checkbutton_assets(self, colorname=DEFAULT):
        """Create the image assets used to build the standard
        checkbutton style.

        Parameters:

            colorname (str):
                The color label used to style the widget.

        Returns:

            tuple[str]:
                A tuple of PhotoImage names.
        """
        # set platform specific checkfont
        winsys = self.style.tk.call("tk", "windowingsystem")
        indicator = "✓"
        if winsys == "win32":
            # Windows font
            fnt = ImageFont.truetype("seguisym.ttf", 120)
            font_offset = -20
            # TODO consider using ImageFont.getsize for offsets
        elif winsys == "x11":
            # Linux fonts
            try:
                # this should be available on most Linux distros
                fnt = ImageFont.truetype("FreeSerif.ttf", 130)
                font_offset = 10
            except:
                try:
                    # this should be available as a backup on Linux 
                    # distros that don't have the FreeSerif.ttf file
                    fnt = ImageFont.truetype("DejaVuSans.ttf", 160)
                    font_offset = -15
                except:
                    # If all else fails, use the default ImageFont
                    # this won't actually show anything in practice 
                    # because of how I'm scaling the image, but it 
                    # will prevent the program from crashing. I need 
                    # a better solution for a missing font
                    fnt = ImageFont.load_default()
                    font_offset = 0
                    indicator = "x"
        else:
            # Mac OS font
            fnt = ImageFont.truetype("LucidaGrande.ttc", 120)
            font_offset = -10

        prime_color = self.colors.get(colorname)
        on_border = prime_color
        on_fill = prime_color
        off_fill = self.colors.bg
        off_border = self.colors.selectbg
        off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
        disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)

        if colorname == LIGHT:
            check_color = self.colors.dark
            on_border = check_color
        elif colorname == DARK:
            check_color = self.colors.light
            on_border = check_color
        else:
            check_color = self.colors.selectfg

        size = self.scale_size([14, 14])

        # checkbutton off
        checkbutton_off = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(checkbutton_off)
        draw.rounded_rectangle(
            [2, 2, 132, 132],
            radius=16,
            outline=off_border,
            width=6,
            fill=off_fill,
        )
        off_img = ImageTk.PhotoImage(
            checkbutton_off.resize(size, Resampling.LANCZOS)
        )
        off_name = util.get_image_name(off_img)
        self.theme_images[off_name] = off_img

        # checkbutton on
        checkbutton_on = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(checkbutton_on)
        draw.rounded_rectangle(
            [2, 2, 132, 132],
            radius=16,
            fill=on_fill,
            outline=on_border,
            width=3,
        )

        draw.text((20, font_offset), indicator, font=fnt, fill=check_color)
        on_img = ImageTk.PhotoImage(checkbutton_on.resize(size, Resampling.LANCZOS))
        on_name = util.get_image_name(on_img)
        self.theme_images[on_name] = on_img

        # checkbutton on/disabled
        checkbutton_on_disabled = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(checkbutton_on_disabled)
        draw.rounded_rectangle(
            [2, 2, 132, 132],
            radius=16,
            fill=disabled_fg,
            outline=disabled_fg,
            width=3,
        )

        draw.text((20, font_offset), indicator, font=fnt, fill=off_fill)
        on_dis_img = ImageTk.PhotoImage(checkbutton_on_disabled.resize(size, Resampling.LANCZOS))
        on_dis_name = util.get_image_name(on_dis_img)
        self.theme_images[on_dis_name] = on_dis_img

        # checkbutton alt
        checkbutton_alt = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(checkbutton_alt)
        draw.rounded_rectangle(
            [2, 2, 132, 132],
            radius=16,
            fill=on_fill,
            outline=on_border,
            width=3,
        )
        draw.line([36, 67, 100, 67], fill=check_color, width=12)
        alt_img = ImageTk.PhotoImage(
            checkbutton_alt.resize(size, Resampling.LANCZOS)
        )
        alt_name = util.get_image_name(alt_img)
        self.theme_images[alt_name] = alt_img

        # checkbutton alt/disabled
        checkbutton_alt_disabled = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(checkbutton_alt_disabled)
        draw.rounded_rectangle(
            [2, 2, 132, 132],
            radius=16,
            fill=disabled_fg,
            outline=disabled_fg,
            width=3,
        )
        draw.line([36, 67, 100, 67], fill=off_fill, width=12)
        alt_dis_img = ImageTk.PhotoImage(
            checkbutton_alt_disabled.resize(size, Resampling.LANCZOS)
        )
        alt_dis_name = util.get_image_name(alt_dis_img)
        self.theme_images[alt_dis_name] = alt_dis_img

        # checkbutton disabled
        checkbutton_disabled = Image.new("RGBA", (134, 134))
        draw = ImageDraw.Draw(checkbutton_disabled)
        draw.rounded_rectangle(
            [2, 2, 132, 132], radius=16, outline=disabled_fg, width=3
        )
        disabled_img = ImageTk.PhotoImage(
            checkbutton_disabled.resize(size, Resampling.LANCZOS)
        )
        disabled_name = util.get_image_name(disabled_img)
        self.theme_images[disabled_name] = disabled_img

        return off_name, on_name, disabled_name, alt_name, on_dis_name, alt_dis_name

    def create_menubutton_style(self, colorname=DEFAULT):
        """Create a solid style for the ttk.Menubutton widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TMenubutton"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            background = self.colors.primary
            foreground = self.colors.get_foreground(PRIMARY)
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            background = self.colors.get(colorname)
            foreground = self.colors.get_foreground(colorname)

        disabled_bg = Colors.make_transparent(0.10, self.colors.fg, self.colors.bg)
        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)
        pressed = Colors.make_transparent(0.80, background, self.colors.bg)
        hover = Colors.make_transparent(0.90, background, self.colors.bg)

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=background,
            bordercolor=background,
            darkcolor=background,
            lightcolor=background,
            arrowsize=self.scale_size(4),
            arrowcolor=foreground,
            arrowpadding=(0, 0, 15, 0),
            relief=tk.RAISED,
            focusthickness=0,
            focuscolor=self.colors.selectfg,
            padding=(10, 5),
        )
        self.style.map(
            ttkstyle,
            arrowcolor=[("disabled", disabled_fg)],
            foreground=[("disabled", disabled_fg)],
            background=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            bordercolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            darkcolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            lightcolor=[
                ("disabled", disabled_bg),
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_outline_menubutton_style(self, colorname=DEFAULT):
        """Create an outline button style for the ttk.Menubutton widget

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "Outline.TMenubutton"

        disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE
            colorname = PRIMARY
        else:
            ttkstyle = f"{colorname}.{STYLE}"

        foreground = self.colors.get(colorname)
        background = self.colors.get_foreground(colorname)
        foreground_pressed = background
        bordercolor = foreground
        pressed = foreground
        hover = foreground

        self.style._build_configure(
            ttkstyle,
            foreground=foreground,
            background=self.colors.bg,
            bordercolor=bordercolor,
            darkcolor=self.colors.bg,
            lightcolor=self.colors.bg,
            relief=tk.RAISED,
            focusthickness=0,
            focuscolor=foreground,
            padding=(10, 5),
            arrowcolor=foreground,
            arrowpadding=(0, 0, 15, 0),
            arrowsize=self.scale_size(4),
        )
        self.style.map(
            ttkstyle,
            foreground=[
                ("disabled", disabled_fg),
                ("pressed !disabled", foreground_pressed),
                ("hover !disabled", foreground_pressed),
            ],
            background=[
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            bordercolor=[
                ("disabled", disabled_fg),
                ("pressed", pressed),
                ("hover", hover),
            ],
            darkcolor=[
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            lightcolor=[
                ("pressed !disabled", pressed),
                ("hover !disabled", hover),
            ],
            arrowcolor=[
                ("disabled", disabled_fg),
                ("pressed", foreground_pressed),
                ("hover", foreground_pressed),
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_notebook_style(self, colorname=DEFAULT):
        """Create a standard style for the ttk.Notebook widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TNotebook"

        if self.is_light_theme:
            bordercolor = self.colors.border
            foreground = self.colors.inputfg
        else:
            bordercolor = self.colors.selectbg
            foreground = self.colors.selectfg

        if any([colorname == DEFAULT, colorname == ""]):
            background = self.colors.inputbg
            selectfg = self.colors.fg
            ttkstyle = STYLE
        else:
            selectfg = self.colors.get_foreground(colorname)
            background = self.colors.get(colorname)
            ttkstyle = f"{colorname}.{STYLE}"

        ttkstyle_tab = f"{ttkstyle}.Tab"

        # create widget style
        self.style._build_configure(
            ttkstyle,
            background=self.colors.bg,
            bordercolor=bordercolor,
            lightcolor=self.colors.bg,
            darkcolor=self.colors.bg,
            tabmargins=(0, 1, 1, 0),
        )
        self.style._build_configure(
            ttkstyle_tab, focuscolor="", foreground=foreground, padding=(6, 5)
        )
        self.style.map(
            ttkstyle_tab,
            background=[
                ("selected", self.colors.bg),
                ("!selected", background),
            ],
            lightcolor=[
                ("selected", self.colors.bg),
                ("!selected", background),
            ],
            bordercolor=[
                ("selected", bordercolor),
                ("!selected", bordercolor),
            ],
            padding=[("selected", (6, 5)), ("!selected", (6, 5))],
            foreground=[("selected", foreground), ("!selected", selectfg)],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def create_panedwindow_style(self, colorname=DEFAULT):
        """Create a standard style for the ttk.Panedwindow widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        H_STYLE = "Horizontal.TPanedwindow"
        V_STYLE = "Vertical.TPanedwindow"

        if self.is_light_theme:
            default_color = self.colors.border
        else:
            default_color = self.colors.selectbg

        if any([colorname == DEFAULT, colorname == ""]):
            sashcolor = default_color
            h_ttkstyle = H_STYLE
            v_ttkstyle = V_STYLE
        else:
            sashcolor = self.colors.get(colorname)
            h_ttkstyle = f"{colorname}.{H_STYLE}"
            v_ttkstyle = f"{colorname}.{V_STYLE}"

        self.style._build_configure(
            "Sash", gripcount=0, sashthickness=self.scale_size(2)
        )
        self.style._build_configure(h_ttkstyle, background=sashcolor)
        self.style._build_configure(v_ttkstyle, background=sashcolor)

        # register ttkstyle
        self.style._register_ttkstyle(h_ttkstyle)
        self.style._register_ttkstyle(v_ttkstyle)

    def create_sizegrip_assets(self, color):
        """Create image assets used to build the sizegrip style.

        Parameters:

            color (str):
                The color _value_ used to draw the image.

        Returns:

            str:
                The PhotoImage name.
        """

        box = self.scale_size(1)
        pad = box * 2
        chunk = box + pad  # 4

        w = chunk * 3 + pad  # 14
        h = chunk * 3 + pad  # 14

        size = [w, h]

        im = Image.new("RGBA", size)
        draw = ImageDraw.Draw(im)

        draw.rectangle((chunk * 2 + pad, pad, chunk * 3, chunk), fill=color)
        draw.rectangle(
            (chunk * 2 + pad, chunk + pad, chunk * 3, chunk * 2), fill=color
        )
        draw.rectangle(
            (chunk * 2 + pad, chunk * 2 + pad, chunk * 3, chunk * 3),
            fill=color,
        )

        draw.rectangle(
            (chunk + pad, chunk + pad, chunk * 2, chunk * 2), fill=color
        )
        draw.rectangle(
            (chunk + pad, chunk * 2 + pad, chunk * 2, chunk * 3), fill=color
        )

        draw.rectangle((pad, chunk * 2 + pad, chunk, chunk * 3), fill=color)

        _img = ImageTk.PhotoImage(im)
        _name = util.get_image_name(_img)
        self.theme_images[_name] = _img
        return _name

    def create_sizegrip_style(self, colorname=DEFAULT):
        """Create a style for the ttk.Sizegrip widget.

        Parameters:

            colorname (str):
                The color label used to style the widget.
        """
        STYLE = "TSizegrip"

        if any([colorname == DEFAULT, colorname == ""]):
            ttkstyle = STYLE

            if self.is_light_theme:
                grip_color = self.colors.border
            else:
                grip_color = self.colors.inputbg
        else:
            ttkstyle = f"{colorname}.{STYLE}"
            grip_color = self.colors.get(colorname)

        image = self.create_sizegrip_assets(grip_color)

        self.style.element_create(
            f"{ttkstyle}.Sizegrip.sizegrip", "image", image
        )
        self.style.layout(
            ttkstyle,
            [
                (
                    f"{ttkstyle}.Sizegrip.sizegrip",
                    {"side": tk.BOTTOM, "sticky": tk.SE},
                )
            ],
        )
        # register ttkstyle
        self.style._register_ttkstyle(ttkstyle)

    def update_combobox_popdown_style(self, widget):
        """Update the legacy ttk.Combobox elements. This method is
        called every time the theme is changed in order to ensure
        that the legacy tkinter components embedded in this ttk widget
        are styled appropriate to the current theme.

        The ttk.Combobox contains several elements that are not styled
        using the ttk theme engine. This includes the **popdownwindow**
        and the **scrollbar**. Both of these widgets are configured
        manually using calls to tcl/tk.

        Parameters:

            widget (ttk.Combobox):
                The combobox element to be updated.
        """
        if self.is_light_theme:
            bordercolor = self.colors.border
        else:
            bordercolor = self.colors.selectbg

        tk_settings = []
        tk_settings.extend(["-borderwidth", 2])
        tk_settings.extend(["-highlightthickness", 1])
        tk_settings.extend(["-highlightcolor", bordercolor])
        tk_settings.extend(["-background", self.colors.inputbg])
        tk_settings.extend(["-foreground", self.colors.inputfg])
        tk_settings.extend(["-selectbackground", self.colors.selectbg])
        tk_settings.extend(["-selectforeground", self.colors.selectfg])

        # set popdown style
        popdown = widget.tk.eval(f"ttk::combobox::PopdownWindow {widget}")
        widget.tk.call(f"{popdown}.f.l", "configure", *tk_settings)

        # set scrollbar style
        sb_style = "TCombobox.Vertical.TScrollbar"
        widget.tk.call(f"{popdown}.f.sb", "configure", "-style", sb_style)

colors property

A reference to the Colors object of the current theme.

is_light_theme property

If the current theme is light, returns True, otherwise returns False.

theme property

A reference to the ThemeDefinition object for the current theme.

create_arrow_assets(arrowcolor, pressed, active)

Create arrow assets used for various widget buttons.

Note

This method is currently not being utilized.

Parameters:

arrowcolor (str):
    The color value to use as the arrow fill color.

pressed (str):
    The color value to use when the arrow is pressed.

active (str):
    The color value to use when the arrow is active or
    hovered.
Source code in src/ttkbootstrap/style.py
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
def create_arrow_assets(self, arrowcolor, pressed, active):
    """Create arrow assets used for various widget buttons.

    !!! note
        This method is currently not being utilized.

    Parameters:

        arrowcolor (str):
            The color value to use as the arrow fill color.

        pressed (str):
            The color value to use when the arrow is pressed.

        active (str):
            The color value to use when the arrow is active or
            hovered.
    """

    def draw_arrow(color: str):
        img = Image.new("RGBA", (11, 11))
        draw = ImageDraw.Draw(img)
        size = self.scale_size([11, 11])

        draw.line([2, 6, 2, 9], fill=color)
        draw.line([3, 5, 3, 8], fill=color)
        draw.line([4, 4, 4, 7], fill=color)
        draw.line([5, 3, 5, 6], fill=color)
        draw.line([6, 4, 6, 7], fill=color)
        draw.line([7, 5, 7, 8], fill=color)
        draw.line([8, 6, 8, 9], fill=color)

        img = img.resize(size, Resampling.BICUBIC)

        up_img = ImageTk.PhotoImage(img)
        up_name = util.get_image_name(up_img)
        self.theme_images[up_name] = up_img

        down_img = ImageTk.PhotoImage(img.rotate(180))
        down_name = util.get_image_name(down_img)
        self.theme_images[down_name] = down_img

        left_img = ImageTk.PhotoImage(img.rotate(90))
        left_name = util.get_image_name(left_img)
        self.theme_images[left_name] = left_img

        right_img = ImageTk.PhotoImage(img.rotate(-90))
        right_name = util.get_image_name(right_img)
        self.theme_images[right_name] = right_img

        return up_name, down_name, left_name, right_name

    normal_names = draw_arrow(arrowcolor)
    pressed_names = draw_arrow(pressed)
    active_names = draw_arrow(active)

    return normal_names, pressed_names, active_names

create_button_style(colorname=DEFAULT)

Create a solid style for the ttk.Button widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_button_style(self, colorname=DEFAULT):
    """Create a solid style for the ttk.Button widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TButton"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        foreground = self.colors.get_foreground(PRIMARY)
        background = self.colors.primary
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        foreground = self.colors.get_foreground(colorname)
        background = self.colors.get(colorname)

    bordercolor = background
    disabled_bg = Colors.make_transparent(0.10, self.colors.fg, self.colors.bg)
    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)
    pressed = Colors.make_transparent(0.80, background, self.colors.bg)
    hover = Colors.make_transparent(0.90, background, self.colors.bg)

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=background,
        bordercolor=bordercolor,
        darkcolor=background,
        lightcolor=background,
        relief=tk.RAISED,
        focusthickness=1,
        focuscolor=foreground,
        padding=(10, 5),
        anchor=tk.CENTER,
    )
    self.style.map(
        ttkstyle,
        foreground=[("disabled", disabled_fg)],
        focuscolor=[("disabled", disabled_fg)],
        background=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        bordercolor=[("disabled", disabled_bg)],
        darkcolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        lightcolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_calendar_style(colorname=DEFAULT)

Create a style for the ttkbootstrap.dialogs.DatePickerPopup widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
def create_calendar_style(self, colorname=DEFAULT):
    """Create a style for the
    ttkbootstrap.dialogs.DatePickerPopup widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """

    STYLE = "TCalendar"

    if any([colorname == DEFAULT, colorname == ""]):
        prime_color = self.colors.primary
        ttkstyle = STYLE
        chevron_style = "Chevron.TButton"
    else:
        prime_color = self.colors.get(colorname)
        ttkstyle = f"{colorname}.{STYLE}"
        chevron_style = f"Chevron.{colorname}.TButton"

    if self.is_light_theme:
        disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.2)
        pressed = Colors.update_hsv(prime_color, vd=-0.1)
    else:
        disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.3)
        pressed = Colors.update_hsv(prime_color, vd=0.1)

    self.style._build_configure(
        ttkstyle,
        foreground=self.colors.fg,
        background=self.colors.bg,
        bordercolor=self.colors.bg,
        darkcolor=self.colors.bg,
        lightcolor=self.colors.bg,
        relief=tk.RAISED,
        focusthickness=1,
        focuscolor=self.colors.fg,
        borderwidth=1,
        padding=(10, 5),
        anchor=tk.CENTER,
    )
    self.style.layout(
        ttkstyle,
        [
            (
                "Toolbutton.border",
                {
                    "sticky": tk.NSEW,
                    "children": [
                        (
                            "Toolbutton.focus",
                            {
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        "Toolbutton.padding",
                                        {
                                            "sticky": tk.NSEW,
                                            "children": [
                                                ("Toolbutton.label", {"sticky": tk.NSEW})
                                            ],
                                        },
                                    )
                                ],
                            },
                        )
                    ],
                },
            )
        ],
    )

    self.style.map(
        ttkstyle,
        foreground=[
            ("disabled", disabled_fg),
            ("pressed !disabled", self.colors.selectfg),
            ("selected !disabled", self.colors.selectfg),
            ("hover !disabled", self.colors.selectfg),
        ],
        background=[
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", pressed),
        ],
        bordercolor=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", pressed),
        ],
        darkcolor=[
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", pressed),
        ],
        lightcolor=[
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", pressed),
        ],
        focuscolor=[
            ("disabled", disabled_fg),
            ("pressed !disabled", self.colors.selectfg),
            ("selected !disabled", self.colors.selectfg),
            ("hover !disabled", self.colors.selectfg),
        ]
    )
    self.style._build_configure(chevron_style, font="-size 14")

    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)
    self.style._register_ttkstyle(chevron_style)

create_checkbutton_assets(colorname=DEFAULT)

Create the image assets used to build the standard checkbutton style.

Parameters:

colorname (str):
    The color label used to style the widget.

Returns:

tuple[str]:
    A tuple of PhotoImage names.
Source code in src/ttkbootstrap/style.py
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
def create_checkbutton_assets(self, colorname=DEFAULT):
    """Create the image assets used to build the standard
    checkbutton style.

    Parameters:

        colorname (str):
            The color label used to style the widget.

    Returns:

        tuple[str]:
            A tuple of PhotoImage names.
    """
    # set platform specific checkfont
    winsys = self.style.tk.call("tk", "windowingsystem")
    indicator = "✓"
    if winsys == "win32":
        # Windows font
        fnt = ImageFont.truetype("seguisym.ttf", 120)
        font_offset = -20
        # TODO consider using ImageFont.getsize for offsets
    elif winsys == "x11":
        # Linux fonts
        try:
            # this should be available on most Linux distros
            fnt = ImageFont.truetype("FreeSerif.ttf", 130)
            font_offset = 10
        except:
            try:
                # this should be available as a backup on Linux 
                # distros that don't have the FreeSerif.ttf file
                fnt = ImageFont.truetype("DejaVuSans.ttf", 160)
                font_offset = -15
            except:
                # If all else fails, use the default ImageFont
                # this won't actually show anything in practice 
                # because of how I'm scaling the image, but it 
                # will prevent the program from crashing. I need 
                # a better solution for a missing font
                fnt = ImageFont.load_default()
                font_offset = 0
                indicator = "x"
    else:
        # Mac OS font
        fnt = ImageFont.truetype("LucidaGrande.ttc", 120)
        font_offset = -10

    prime_color = self.colors.get(colorname)
    on_border = prime_color
    on_fill = prime_color
    off_fill = self.colors.bg
    off_border = self.colors.selectbg
    off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
    disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)

    if colorname == LIGHT:
        check_color = self.colors.dark
        on_border = check_color
    elif colorname == DARK:
        check_color = self.colors.light
        on_border = check_color
    else:
        check_color = self.colors.selectfg

    size = self.scale_size([14, 14])

    # checkbutton off
    checkbutton_off = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(checkbutton_off)
    draw.rounded_rectangle(
        [2, 2, 132, 132],
        radius=16,
        outline=off_border,
        width=6,
        fill=off_fill,
    )
    off_img = ImageTk.PhotoImage(
        checkbutton_off.resize(size, Resampling.LANCZOS)
    )
    off_name = util.get_image_name(off_img)
    self.theme_images[off_name] = off_img

    # checkbutton on
    checkbutton_on = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(checkbutton_on)
    draw.rounded_rectangle(
        [2, 2, 132, 132],
        radius=16,
        fill=on_fill,
        outline=on_border,
        width=3,
    )

    draw.text((20, font_offset), indicator, font=fnt, fill=check_color)
    on_img = ImageTk.PhotoImage(checkbutton_on.resize(size, Resampling.LANCZOS))
    on_name = util.get_image_name(on_img)
    self.theme_images[on_name] = on_img

    # checkbutton on/disabled
    checkbutton_on_disabled = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(checkbutton_on_disabled)
    draw.rounded_rectangle(
        [2, 2, 132, 132],
        radius=16,
        fill=disabled_fg,
        outline=disabled_fg,
        width=3,
    )

    draw.text((20, font_offset), indicator, font=fnt, fill=off_fill)
    on_dis_img = ImageTk.PhotoImage(checkbutton_on_disabled.resize(size, Resampling.LANCZOS))
    on_dis_name = util.get_image_name(on_dis_img)
    self.theme_images[on_dis_name] = on_dis_img

    # checkbutton alt
    checkbutton_alt = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(checkbutton_alt)
    draw.rounded_rectangle(
        [2, 2, 132, 132],
        radius=16,
        fill=on_fill,
        outline=on_border,
        width=3,
    )
    draw.line([36, 67, 100, 67], fill=check_color, width=12)
    alt_img = ImageTk.PhotoImage(
        checkbutton_alt.resize(size, Resampling.LANCZOS)
    )
    alt_name = util.get_image_name(alt_img)
    self.theme_images[alt_name] = alt_img

    # checkbutton alt/disabled
    checkbutton_alt_disabled = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(checkbutton_alt_disabled)
    draw.rounded_rectangle(
        [2, 2, 132, 132],
        radius=16,
        fill=disabled_fg,
        outline=disabled_fg,
        width=3,
    )
    draw.line([36, 67, 100, 67], fill=off_fill, width=12)
    alt_dis_img = ImageTk.PhotoImage(
        checkbutton_alt_disabled.resize(size, Resampling.LANCZOS)
    )
    alt_dis_name = util.get_image_name(alt_dis_img)
    self.theme_images[alt_dis_name] = alt_dis_img

    # checkbutton disabled
    checkbutton_disabled = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(checkbutton_disabled)
    draw.rounded_rectangle(
        [2, 2, 132, 132], radius=16, outline=disabled_fg, width=3
    )
    disabled_img = ImageTk.PhotoImage(
        checkbutton_disabled.resize(size, Resampling.LANCZOS)
    )
    disabled_name = util.get_image_name(disabled_img)
    self.theme_images[disabled_name] = disabled_img

    return off_name, on_name, disabled_name, alt_name, on_dis_name, alt_dis_name

create_checkbutton_style(colorname=DEFAULT)

Create a standard style for the ttk.Checkbutton widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
def create_checkbutton_style(self, colorname=DEFAULT):
    """Create a standard style for the ttk.Checkbutton widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TCheckbutton"

    disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        colorname = PRIMARY
        ttkstyle = STYLE
    else:
        ttkstyle = f"{colorname}.TCheckbutton"

    # ( off, on, disabled )
    images = self.create_checkbutton_assets(colorname)

    element = ttkstyle.replace(".TC", ".C")
    width = self.scale_size(20)
    borderpad = self.scale_size(4)
    self.style.element_create(
        f"{element}.indicator",
        "image",
        images[1],
        ("disabled selected", images[4]),
        ("disabled alternate", images[5]),
        ("disabled", images[2]),
        ("alternate", images[3]),
        ("!selected", images[0]),
        width=width,
        border=borderpad,
        sticky=tk.W,
    )
    self.style._build_configure(ttkstyle, foreground=self.colors.fg)
    self.style.map(ttkstyle, foreground=[("disabled", disabled_fg)])
    self.style.layout(
        ttkstyle,
        [
            (
                "Checkbutton.padding",
                {
                    "children": [
                        (
                            f"{element}.indicator",
                            {"side": tk.LEFT, "sticky": ""},
                        ),
                        (
                            "Checkbutton.focus",
                            {
                                "children": [
                                    (
                                        "Checkbutton.label",
                                        {"sticky": tk.NSEW},
                                    )
                                ],
                                "side": tk.LEFT,
                                "sticky": "",
                            },
                        ),
                    ],
                    "sticky": tk.NSEW,
                },
            )
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_combobox_style(colorname=DEFAULT)

Create a style for the ttk.Combobox widget.

Parameters:

colorname (str):
    The color label to use as the primary widget color.
Source code in src/ttkbootstrap/style.py
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
def create_combobox_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Combobox widget.

    Parameters:

        colorname (str):
            The color label to use as the primary widget color.
    """
    STYLE = "TCombobox"

    if self.is_light_theme:
        disabled_fg = self.colors.border
        bordercolor = self.colors.border
        readonly = self.colors.light
    else:
        disabled_fg = self.colors.selectbg
        bordercolor = self.colors.selectbg
        readonly = bordercolor

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        element = f"{ttkstyle.replace('TC', 'C')}"
        focuscolor = self.colors.primary
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        element = f"{ttkstyle.replace('TC', 'C')}"
        focuscolor = self.colors.get(colorname)

    # Create custom arrow assets since the default ones don't work with Tcl/Tk bundled in python 3.13
    arrow_images = self.create_simple_arrow_assets(
        self.colors.inputfg,
        disabled_fg,
        focuscolor,
    )
    downarrow_image = arrow_images[0][1]
    downarrow_disabled_image = arrow_images[1][1]
    downarrow_focused_image = arrow_images[2][1]
    self.style.element_create(
        f"{element}.downarrow",
        "image",
        downarrow_image,
        ("disabled", downarrow_disabled_image),
        ("pressed !disabled", downarrow_focused_image),
        ("focus !disabled", downarrow_focused_image),
        ("hover !disabled", downarrow_focused_image),
    )
    #  self.style.element_create(f"{element}.downarrow", "from", TTK_DEFAULT)  # doesn't work in python 3.13
    self.style.element_create(f"{element}.padding", "from", TTK_CLAM)
    self.style.element_create(f"{element}.textarea", "from", TTK_CLAM)

    if all([colorname, colorname != DEFAULT]):
        bordercolor = focuscolor

    self.style._build_configure(
        ttkstyle,
        bordercolor=bordercolor,
        darkcolor=self.colors.inputbg,
        lightcolor=self.colors.inputbg,
        foreground=self.colors.inputfg,
        fieldbackground=self.colors.inputbg,
        background=self.colors.inputbg,
        insertcolor=self.colors.inputfg,
        relief=tk.FLAT,
        padding=5,
    )
    self.style.map(
        ttkstyle,
        background=[("readonly", readonly)],
        fieldbackground=[("readonly", readonly)],
        foreground=[("disabled", disabled_fg)],
        bordercolor=[
            ("invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("hover !disabled", focuscolor),
        ],
        lightcolor=[
            ("focus invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("pressed !disabled", focuscolor),
            ("readonly", readonly),
        ],
        darkcolor=[
            ("focus invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("pressed !disabled", focuscolor),
            ("readonly", readonly),
        ],
    )
    self.style.layout(
        ttkstyle,
        [
            (
                "combo.Spinbox.field",
                {
                    "side": tk.TOP,
                    "sticky": tk.EW,
                    "children": [
                        (
                            "Combobox.downarrow",
                            {"side": tk.RIGHT, "sticky": tk.S},
                        ),
                        (
                            "Combobox.padding",
                            {
                                "expand": "1",
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        "Combobox.textarea",
                                        {"sticky": tk.NSEW},
                                    )
                                ],
                            },
                        ),
                    ],
                },
            )
        ],
    )
    self.style._register_ttkstyle(ttkstyle)
    try:
        self.create_scrollbar_style()
    except Exception:
        # style already created
        pass

create_date_button_assets(foreground)

Create the image assets used to build the date button style. This button style applied to the button in the ttkbootstrap.widgets.DateEntry.

Parameters:

foreground (str):
    The color value used to draw the calendar image.

Returns:

str:
    The PhotoImage name.
Source code in src/ttkbootstrap/style.py
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
def create_date_button_assets(self, foreground):
    """Create the image assets used to build the date button
    style. This button style applied to the button in the
    ttkbootstrap.widgets.DateEntry.

    Parameters:

        foreground (str):
            The color value used to draw the calendar image.

    Returns:

        str:
            The PhotoImage name.
    """
    fill = foreground
    image = Image.new("RGBA", (210, 220))
    draw = ImageDraw.Draw(image)

    draw.rounded_rectangle(
        [10, 30, 200, 210], radius=20, outline=fill, width=10
    )

    calendar_image_coordinates = [
        # page spirals
        [40, 10, 50, 50],
        [100, 10, 110, 50],
        [160, 10, 170, 50],
        # row 1
        [70, 90, 90, 110],
        [110, 90, 130, 110],
        [150, 90, 170, 110],
        # row 2
        [30, 130, 50, 150],
        [70, 130, 90, 150],
        [110, 130, 130, 150],
        [150, 130, 170, 150],
        # row 3
        [30, 170, 50, 190],
        [70, 170, 90, 190],
        [110, 170, 130, 190],
    ]
    for xy in calendar_image_coordinates:
        draw.rectangle(xy=xy, fill=fill)

    size = self.scale_size([21, 22])
    tk_img = ImageTk.PhotoImage(image.resize(size, Resampling.LANCZOS))
    tk_name = util.get_image_name(tk_img)
    self.theme_images[tk_name] = tk_img
    return tk_name

create_date_button_style(colorname=DEFAULT)

Create a date button style for the ttk.Button widget.

Parameters:

colorname (str):
    The color label used to style widget.
Source code in src/ttkbootstrap/style.py
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
def create_date_button_style(self, colorname=DEFAULT):
    """Create a date button style for the ttk.Button widget.

    Parameters:

        colorname (str):
            The color label used to style widget.
    """
    STYLE = "Date.TButton"

    if self.is_light_theme:
        disabled_fg = self.colors.border
    else:
        disabled_fg = self.colors.selectbg

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        foreground = self.colors.get_foreground(PRIMARY)
        background = self.colors.primary
        btn_foreground = Colors.get_foreground(self.colors, PRIMARY)
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        foreground = self.colors.get_foreground(colorname)
        background = self.colors.get(colorname)
        btn_foreground = Colors.get_foreground(self.colors, colorname)

    img_normal = self.create_date_button_assets(btn_foreground)

    pressed = Colors.update_hsv(background, vd=-0.1)
    hover = Colors.update_hsv(background, vd=0.10)

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=background,
        bordercolor=background,
        darkcolor=background,
        lightcolor=background,
        relief=tk.RAISED,
        focusthickness=0,
        focuscolor=foreground,
        padding=(2, 2),
        anchor=tk.CENTER,
        image=img_normal,
    )
    self.style.map(
        ttkstyle,
        foreground=[("disabled", disabled_fg)],
        background=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        bordercolor=[("disabled", disabled_fg)],
        darkcolor=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        lightcolor=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
    )

    self.style._register_ttkstyle(ttkstyle)

create_default_style()

Setup the default widget style configuration for the root ttk style "."; these defaults are applied to any widget that contains the configuration options updated by this style. This method should be called first before any other style is applied during theme creation.

Source code in src/ttkbootstrap/style.py
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
def create_default_style(self):
    """Setup the default widget style configuration for the root
    ttk style "."; these defaults are applied to any widget that
    contains the configuration options updated by this style. This
    method should be called *first* before any other style is applied
    during theme creation.
    """
    self.style._build_configure(
        style=".",
        background=self.colors.bg,
        darkcolor=self.colors.border,
        foreground=self.colors.fg,
        troughcolor=self.colors.bg,
        selectbg=self.colors.selectbg,
        selectfg=self.colors.selectfg,
        selectforeground=self.colors.selectfg,
        selectbackground=self.colors.selectbg,
        fieldbg="white",
        borderwidth=1,
        focuscolor="",
    )
    # this is general style applied to the tableview
    self.create_link_button_style()
    self.style.configure("symbol.Link.TButton", font="-size 16")

    # this is the general style applied to the tooltip
    self.create_label_style()
    self.style.configure(
        style="tooltip.TLabel",
        background="#fffddd",
        foreground="#333",
        bordercolor="#888",
        borderwidth=1,
        darkcolor="#fffddd",
        lightcolor="#fffddd",
        relief=RAISED,
    )

create_entry_style(colorname=DEFAULT)

Create a style for the ttk.Entry widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
def create_entry_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Entry widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TEntry"

    # general default colors
    if self.is_light_theme:
        disabled_fg = self.colors.border
        bordercolor = self.colors.border
        readonly = self.colors.light
    else:
        disabled_fg = self.colors.selectbg
        bordercolor = self.colors.selectbg
        readonly = bordercolor

    if any([colorname == DEFAULT, not colorname]):
        # default style
        ttkstyle = STYLE
        focuscolor = self.colors.primary
    else:
        # colored style
        ttkstyle = f"{colorname}.{STYLE}"
        focuscolor = self.colors.get(colorname)
        bordercolor = focuscolor

    self.style._build_configure(
        ttkstyle,
        bordercolor=bordercolor,
        darkcolor=self.colors.inputbg,
        lightcolor=self.colors.inputbg,
        fieldbackground=self.colors.inputbg,
        foreground=self.colors.inputfg,
        insertcolor=self.colors.inputfg,
        padding=5,
    )
    self.style.map(
        ttkstyle,
        foreground=[("disabled", disabled_fg)],
        fieldbackground=[("readonly", readonly)],
        bordercolor=[
            ("invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("hover !disabled", focuscolor),
        ],
        lightcolor=[
            ("focus invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("readonly", readonly),
        ],
        darkcolor=[
            ("focus invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("readonly", readonly),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_floodgauge_style(colorname=DEFAULT)

Create a ttk style for the ttkbootstrap.widgets.Floodgauge widget. This is a custom widget style that uses components of the progressbar and label.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_floodgauge_style(self, colorname=DEFAULT):
    """Create a ttk style for the ttkbootstrap.widgets.Floodgauge
    widget. This is a custom widget style that uses components of
    the progressbar and label.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    HSTYLE = "Horizontal.TFloodgauge"
    VSTYLE = "Vertical.TFloodgauge"
    FLOOD_FONT = "-size 14"

    if any([colorname == DEFAULT, colorname == ""]):
        h_ttkstyle = HSTYLE
        v_ttkstyle = VSTYLE
        background = self.colors.primary
    else:
        h_ttkstyle = f"{colorname}.{HSTYLE}"
        v_ttkstyle = f"{colorname}.{VSTYLE}"
        background = self.colors.get(colorname)

    if colorname == LIGHT:
        foreground = self.colors.fg
        troughcolor = self.colors.bg
    else:
        troughcolor = Colors.update_hsv(background, sd=-0.3, vd=0.8)
        foreground = self.colors.selectfg

    # horizontal floodgauge
    h_element = h_ttkstyle.replace(".TF", ".F")
    self.style.element_create(f"{h_element}.trough", "from", TTK_CLAM)
    self.style.element_create(f"{h_element}.pbar", "from", TTK_DEFAULT)
    self.style.layout(
        h_ttkstyle,
        [
            (
                f"{h_element}.trough",
                {
                    "children": [
                        (f"{h_element}.pbar", {"sticky": tk.NS}),
                        ("Floodgauge.label", {"sticky": ""}),
                    ],
                    "sticky": tk.NSEW,
                },
            )
        ],
    )
    self.style._build_configure(
        h_ttkstyle,
        thickness=50,
        borderwidth=1,
        bordercolor=background,
        lightcolor=background,
        pbarrelief=tk.FLAT,
        troughcolor=troughcolor,
        background=background,
        foreground=foreground,
        justify=tk.CENTER,
        anchor=tk.CENTER,
        font=FLOOD_FONT,
    )
    # vertical floodgauge
    v_element = v_ttkstyle.replace(".TF", ".F")
    self.style.element_create(f"{v_element}.trough", "from", TTK_CLAM)
    self.style.element_create(f"{v_element}.pbar", "from", TTK_DEFAULT)
    self.style.layout(
        v_ttkstyle,
        [
            (
                f"{v_element}.trough",
                {
                    "children": [
                        (f"{v_element}.pbar", {"sticky": tk.EW}),
                        ("Floodgauge.label", {"sticky": ""}),
                    ],
                    "sticky": tk.NSEW,
                },
            )
        ],
    )
    self.style._build_configure(
        v_ttkstyle,
        thickness=50,
        borderwidth=1,
        bordercolor=background,
        lightcolor=background,
        pbarrelief=tk.FLAT,
        troughcolor=troughcolor,
        background=background,
        foreground=foreground,
        justify=tk.CENTER,
        anchor=tk.CENTER,
        font=FLOOD_FONT,
    )
    # register ttkstyles
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_frame_style(colorname=DEFAULT)

Create a style for the ttk.Frame widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
def create_frame_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Frame widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TFrame"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        background = self.colors.bg
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        background = self.colors.get(colorname)

    self.style._build_configure(ttkstyle, background=background)

    # register style
    self.style._register_ttkstyle(ttkstyle)

create_inverse_label_style(colorname=DEFAULT)

Create an inverted style for the ttk.Label.

The foreground and background are inverted versions of that used in the standard label style.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
def create_inverse_label_style(self, colorname=DEFAULT):
    """Create an inverted style for the ttk.Label.

    The foreground and background are inverted versions of that
    used in the standard label style.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE_INVERSE = "Inverse.TLabel"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE_INVERSE
        background = self.colors.fg
        foreground = self.colors.bg
    else:
        ttkstyle = f"{colorname}.{STYLE_INVERSE}"
        background = self.colors.get(colorname)
        foreground = self.colors.get_foreground(colorname)

    self.style._build_configure(
        ttkstyle, foreground=foreground, background=background
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_label_style(colorname=DEFAULT)

Create a standard style for the ttk.Label widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
def create_label_style(self, colorname=DEFAULT):
    """Create a standard style for the ttk.Label widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TLabel"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        foreground = self.colors.fg
        background = self.colors.bg
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        foreground = self.colors.get(colorname)
        background = self.colors.bg

    # standard label
    self.style._build_configure(
        ttkstyle, foreground=foreground, background=background
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_labelframe_style(colorname=DEFAULT)

Create a style for the ttk.Labelframe widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
def create_labelframe_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Labelframe widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TLabelframe"

    background = self.colors.bg

    if any([colorname == DEFAULT, colorname == ""]):
        foreground = self.colors.fg
        ttkstyle = STYLE

        if self.is_light_theme:
            bordercolor = self.colors.border
        else:
            bordercolor = self.colors.selectbg

    else:
        foreground = self.colors.get(colorname)
        bordercolor = foreground
        ttkstyle = f"{colorname}.{STYLE}"

    # create widget style
    self.style._build_configure(
        f"{ttkstyle}.Label",
        foreground=foreground,
        background=background,
    )
    self.style._build_configure(
        ttkstyle,
        relief=tk.RAISED,
        borderwidth=1,
        bordercolor=bordercolor,
        lightcolor=background,
        darkcolor=background,
        background=background,
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

Create a link button style for the ttk.Button widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
def create_link_button_style(self, colorname=DEFAULT):
    """Create a link button style for the ttk.Button widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Link.TButton"

    pressed = self.colors.info
    hover = self.colors.info

    if any([colorname == DEFAULT, colorname == ""]):
        foreground = self.colors.fg
        ttkstyle = STYLE
    elif colorname == LIGHT:
        foreground = self.colors.fg
        ttkstyle = f"{colorname}.{STYLE}"
    else:
        foreground = self.colors.get(colorname)
        ttkstyle = f"{colorname}.{STYLE}"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=self.colors.bg,
        bordercolor=self.colors.bg,
        darkcolor=self.colors.bg,
        lightcolor=self.colors.bg,
        relief=tk.RAISED,
        focusthickness=1,
        focuscolor=foreground,
        anchor=tk.CENTER,
        padding=(10, 5),
    )
    self.style.map(
        ttkstyle,
        shiftrelief=[("pressed !disabled", -1)],
        foreground=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        focuscolor=[
            ("pressed !disabled", pressed),
            ("hover !disabled", pressed),
        ],
        background=[
            ("disabled", self.colors.bg),
            ("pressed !disabled", self.colors.bg),
            ("hover !disabled", self.colors.bg),
        ],
        bordercolor=[
            ("disabled", self.colors.bg),
            ("pressed !disabled", self.colors.bg),
            ("hover !disabled", self.colors.bg),
        ],
        darkcolor=[
            ("disabled", self.colors.bg),
            ("pressed !disabled", self.colors.bg),
            ("hover !disabled", self.colors.bg),
        ],
        lightcolor=[
            ("disabled", self.colors.bg),
            ("pressed !disabled", self.colors.bg),
            ("hover !disabled", self.colors.bg),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_menubutton_style(colorname=DEFAULT)

Create a solid style for the ttk.Menubutton widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
def create_menubutton_style(self, colorname=DEFAULT):
    """Create a solid style for the ttk.Menubutton widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TMenubutton"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        background = self.colors.primary
        foreground = self.colors.get_foreground(PRIMARY)
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        background = self.colors.get(colorname)
        foreground = self.colors.get_foreground(colorname)

    disabled_bg = Colors.make_transparent(0.10, self.colors.fg, self.colors.bg)
    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)
    pressed = Colors.make_transparent(0.80, background, self.colors.bg)
    hover = Colors.make_transparent(0.90, background, self.colors.bg)

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=background,
        bordercolor=background,
        darkcolor=background,
        lightcolor=background,
        arrowsize=self.scale_size(4),
        arrowcolor=foreground,
        arrowpadding=(0, 0, 15, 0),
        relief=tk.RAISED,
        focusthickness=0,
        focuscolor=self.colors.selectfg,
        padding=(10, 5),
    )
    self.style.map(
        ttkstyle,
        arrowcolor=[("disabled", disabled_fg)],
        foreground=[("disabled", disabled_fg)],
        background=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        bordercolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        darkcolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        lightcolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_meter_label_style(colorname=DEFAULT)

Create a label style for the ttkbootstrap.widgets.Meter widget. This style also stores some metadata that is called by the Meter class to lookup relevant colors for the trough and bar when the new image is drawn.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
def create_meter_label_style(self, colorname=DEFAULT):
    """Create a label style for the
    ttkbootstrap.widgets.Meter widget. This style also stores some
    metadata that is called by the Meter class to lookup relevant
    colors for the trough and bar when the new image is drawn.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """

    STYLE = "Meter.TLabel"

    # text color = `foreground`
    # trough color = `space`

    if self.is_light_theme:
        if colorname == LIGHT:
            troughcolor = self.colors.bg
        else:
            troughcolor = self.colors.light
    else:
        troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        background = self.colors.bg
        textcolor = self.colors.primary
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        textcolor = self.colors.get(colorname)
        background = self.colors.bg

    self.style._build_configure(
        ttkstyle,
        foreground=textcolor,
        background=background,
        space=troughcolor,
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_metersubtxt_label_style(colorname=DEFAULT)

Create a subtext label style for the ttkbootstrap.widgets.Meter widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
def create_metersubtxt_label_style(self, colorname=DEFAULT):
    """Create a subtext label style for the
    ttkbootstrap.widgets.Meter widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Metersubtxt.TLabel"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        if self.is_light_theme:
            foreground = self.colors.secondary
        else:
            foreground = self.colors.light
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        foreground = self.colors.get(colorname)

    background = self.colors.bg

    self.style._build_configure(
        ttkstyle, foreground=foreground, background=background
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_notebook_style(colorname=DEFAULT)

Create a standard style for the ttk.Notebook widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
def create_notebook_style(self, colorname=DEFAULT):
    """Create a standard style for the ttk.Notebook widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TNotebook"

    if self.is_light_theme:
        bordercolor = self.colors.border
        foreground = self.colors.inputfg
    else:
        bordercolor = self.colors.selectbg
        foreground = self.colors.selectfg

    if any([colorname == DEFAULT, colorname == ""]):
        background = self.colors.inputbg
        selectfg = self.colors.fg
        ttkstyle = STYLE
    else:
        selectfg = self.colors.get_foreground(colorname)
        background = self.colors.get(colorname)
        ttkstyle = f"{colorname}.{STYLE}"

    ttkstyle_tab = f"{ttkstyle}.Tab"

    # create widget style
    self.style._build_configure(
        ttkstyle,
        background=self.colors.bg,
        bordercolor=bordercolor,
        lightcolor=self.colors.bg,
        darkcolor=self.colors.bg,
        tabmargins=(0, 1, 1, 0),
    )
    self.style._build_configure(
        ttkstyle_tab, focuscolor="", foreground=foreground, padding=(6, 5)
    )
    self.style.map(
        ttkstyle_tab,
        background=[
            ("selected", self.colors.bg),
            ("!selected", background),
        ],
        lightcolor=[
            ("selected", self.colors.bg),
            ("!selected", background),
        ],
        bordercolor=[
            ("selected", bordercolor),
            ("!selected", bordercolor),
        ],
        padding=[("selected", (6, 5)), ("!selected", (6, 5))],
        foreground=[("selected", foreground), ("!selected", selectfg)],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_outline_button_style(colorname=DEFAULT)

Create an outline style for the ttk.Button widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
def create_outline_button_style(self, colorname=DEFAULT):
    """Create an outline style for the ttk.Button widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Outline.TButton"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        colorname = PRIMARY
    else:
        ttkstyle = f"{colorname}.{STYLE}"

    foreground = self.colors.get(colorname)
    background = self.colors.get_foreground(colorname)
    foreground_pressed = background
    bordercolor = foreground
    pressed = foreground
    hover = foreground

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=self.colors.bg,
        bordercolor=bordercolor,
        darkcolor=self.colors.bg,
        lightcolor=self.colors.bg,
        relief=tk.RAISED,
        focusthickness=1,
        focuscolor=foreground,
        padding=(10, 5),
        anchor=tk.CENTER,
    )
    self.style.map(
        ttkstyle,
        foreground=[
            ("disabled", disabled_fg),
            ("pressed !disabled", foreground_pressed),
            ("hover !disabled", foreground_pressed),
        ],
        background=[
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        bordercolor=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        focuscolor=[
            ("pressed !disabled", foreground_pressed),
            ("hover !disabled", foreground_pressed),
        ],
        darkcolor=[
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        lightcolor=[
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_outline_menubutton_style(colorname=DEFAULT)

Create an outline button style for the ttk.Menubutton widget

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
def create_outline_menubutton_style(self, colorname=DEFAULT):
    """Create an outline button style for the ttk.Menubutton widget

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Outline.TMenubutton"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        colorname = PRIMARY
    else:
        ttkstyle = f"{colorname}.{STYLE}"

    foreground = self.colors.get(colorname)
    background = self.colors.get_foreground(colorname)
    foreground_pressed = background
    bordercolor = foreground
    pressed = foreground
    hover = foreground

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=self.colors.bg,
        bordercolor=bordercolor,
        darkcolor=self.colors.bg,
        lightcolor=self.colors.bg,
        relief=tk.RAISED,
        focusthickness=0,
        focuscolor=foreground,
        padding=(10, 5),
        arrowcolor=foreground,
        arrowpadding=(0, 0, 15, 0),
        arrowsize=self.scale_size(4),
    )
    self.style.map(
        ttkstyle,
        foreground=[
            ("disabled", disabled_fg),
            ("pressed !disabled", foreground_pressed),
            ("hover !disabled", foreground_pressed),
        ],
        background=[
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        bordercolor=[
            ("disabled", disabled_fg),
            ("pressed", pressed),
            ("hover", hover),
        ],
        darkcolor=[
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        lightcolor=[
            ("pressed !disabled", pressed),
            ("hover !disabled", hover),
        ],
        arrowcolor=[
            ("disabled", disabled_fg),
            ("pressed", foreground_pressed),
            ("hover", foreground_pressed),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_outline_toolbutton_style(colorname=DEFAULT)

Create an outline toolbutton style for the ttk.Checkbutton and ttk.Radiobutton widgets.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
def create_outline_toolbutton_style(self, colorname=DEFAULT):
    """Create an outline toolbutton style for the ttk.Checkbutton
    and ttk.Radiobutton widgets.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Outline.Toolbutton"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        colorname = PRIMARY
    else:
        ttkstyle = f"{colorname}.{STYLE}"

    foreground = self.colors.get(colorname)
    background = self.colors.get_foreground(colorname)
    foreground_pressed = background
    bordercolor = foreground
    pressed = foreground
    hover = foreground

    self.style._build_configure(
        ttkstyle,
        foreground=foreground,
        background=self.colors.bg,
        bordercolor=bordercolor,
        darkcolor=self.colors.bg,
        lightcolor=self.colors.bg,
        relief=tk.RAISED,
        focusthickness=0,
        focuscolor=foreground,
        padding=(10, 5),
        anchor=tk.CENTER,
        arrowcolor=foreground,
        arrowpadding=(0, 0, 15, 0),
        arrowsize=3,
    )
    self.style.map(
        ttkstyle,
        foreground=[
            ("disabled", disabled_fg),
            ("pressed !disabled", foreground_pressed),
            ("selected !disabled", foreground_pressed),
            ("hover !disabled", foreground_pressed),
        ],
        background=[
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", hover),
        ],
        bordercolor=[
            ("disabled", disabled_fg),
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", hover),
        ],
        darkcolor=[
            ("disabled", self.colors.bg),
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", hover),
        ],
        lightcolor=[
            ("disabled", self.colors.bg),
            ("pressed !disabled", pressed),
            ("selected !disabled", pressed),
            ("hover !disabled", hover),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_panedwindow_style(colorname=DEFAULT)

Create a standard style for the ttk.Panedwindow widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
def create_panedwindow_style(self, colorname=DEFAULT):
    """Create a standard style for the ttk.Panedwindow widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    H_STYLE = "Horizontal.TPanedwindow"
    V_STYLE = "Vertical.TPanedwindow"

    if self.is_light_theme:
        default_color = self.colors.border
    else:
        default_color = self.colors.selectbg

    if any([colorname == DEFAULT, colorname == ""]):
        sashcolor = default_color
        h_ttkstyle = H_STYLE
        v_ttkstyle = V_STYLE
    else:
        sashcolor = self.colors.get(colorname)
        h_ttkstyle = f"{colorname}.{H_STYLE}"
        v_ttkstyle = f"{colorname}.{V_STYLE}"

    self.style._build_configure(
        "Sash", gripcount=0, sashthickness=self.scale_size(2)
    )
    self.style._build_configure(h_ttkstyle, background=sashcolor)
    self.style._build_configure(v_ttkstyle, background=sashcolor)

    # register ttkstyle
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_progressbar_style(colorname=DEFAULT)

Create a solid ttk style for the ttk.Progressbar widget.

Parameters:

colorname (str):
    The primary widget color.
Source code in src/ttkbootstrap/style.py
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
def create_progressbar_style(self, colorname=DEFAULT):
    """Create a solid ttk style for the ttk.Progressbar widget.

    Parameters:

        colorname (str):
            The primary widget color.
    """
    H_STYLE = "Horizontal.TProgressbar"
    V_STYLE = "Vertical.TProgressbar"

    thickness = self.scale_size(10)

    if self.is_light_theme:
        if colorname == LIGHT:
            troughcolor = self.colors.bg
            bordercolor = self.colors.light
        else:
            troughcolor = self.colors.light
            bordercolor = troughcolor
    else:
        troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)
        bordercolor = troughcolor

    if any([colorname == DEFAULT, colorname == ""]):
        background = self.colors.primary
        h_ttkstyle = H_STYLE
        v_ttkstyle = V_STYLE
    else:
        background = self.colors.get(colorname)
        h_ttkstyle = f"{colorname}.{H_STYLE}"
        v_ttkstyle = f"{colorname}.{V_STYLE}"

    self.style._build_configure(
        h_ttkstyle,
        thickness=thickness,
        borderwidth=1,
        bordercolor=bordercolor,
        lightcolor=self.colors.border,
        pbarrelief=tk.FLAT,
        troughcolor=troughcolor,
    )
    existing_elements = self.style.element_names()

    self.style._build_configure(
        v_ttkstyle,
        thickness=thickness,
        borderwidth=1,
        bordercolor=bordercolor,
        lightcolor=self.colors.border,
        pbarrelief=tk.FLAT,
        troughcolor=troughcolor,
    )
    existing_elements = self.style.element_names()

    # horizontal progressbar
    h_element = h_ttkstyle.replace(".TP", ".P")
    trough_element = f"{h_element}.trough"
    pbar_element = f"{h_element}.pbar"
    if trough_element not in existing_elements:
        self.style.element_create(trough_element, "from", TTK_CLAM)
        self.style.element_create(pbar_element, "from", TTK_DEFAULT)

    self.style.layout(
        h_ttkstyle,
        [
            (
                trough_element,
                {
                    "sticky": "nswe",
                    "children": [
                        (pbar_element, {"side": "left", "sticky": "ns"})
                    ],
                },
            )
        ],
    )
    self.style._build_configure(h_ttkstyle, background=background)

    # vertical progressbar
    v_element = v_ttkstyle.replace(".TP", ".P")
    trough_element = f"{v_element}.trough"
    pbar_element = f"{v_element}.pbar"
    if trough_element not in existing_elements:
        self.style.element_create(trough_element, "from", TTK_CLAM)
        self.style.element_create(pbar_element, "from", TTK_DEFAULT)
        self.style._build_configure(v_ttkstyle, background=background)
    self.style.layout(
        v_ttkstyle,
        [
            (
                trough_element,
                {
                    "sticky": "nswe",
                    "children": [
                        (pbar_element, {"side": "bottom", "sticky": "we"})
                    ],
                },
            )
        ],
    )

    # register ttkstyles
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_radiobutton_assets(colorname=DEFAULT)

Create the image assets used to build the radiobutton style.

Parameters:

colorname (str):

Returns:

tuple[str]:
    A tuple of PhotoImage names
Source code in src/ttkbootstrap/style.py
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
def create_radiobutton_assets(self, colorname=DEFAULT):
    """Create the image assets used to build the radiobutton style.

    Parameters:

        colorname (str):

    Returns:

        tuple[str]:
            A tuple of PhotoImage names
    """
    prime_color = self.colors.get(colorname)
    on_fill = prime_color
    off_fill = self.colors.bg
    on_indicator = self.colors.selectfg
    size = self.scale_size([14, 14])
    off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
    disabled = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)

    if self.is_light_theme:
        if colorname == LIGHT:
            on_indicator = self.colors.dark

    # radio off
    _off = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(_off)
    draw.ellipse(
        xy=[1, 1, 133, 133], outline=off_border, width=6, fill=off_fill
    )
    off_img = ImageTk.PhotoImage(_off.resize(size, Resampling.LANCZOS))
    off_name = util.get_image_name(off_img)
    self.theme_images[off_name] = off_img

    # radio on
    _on = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(_on)
    if colorname == LIGHT and self.is_light_theme:
        draw.ellipse(xy=[1, 1, 133, 133], outline=off_border, width=6)
    else:
        draw.ellipse(xy=[1, 1, 133, 133], fill=on_fill)
    draw.ellipse([40, 40, 94, 94], fill=on_indicator)
    on_img = ImageTk.PhotoImage(_on.resize(size, Resampling.LANCZOS))
    on_name = util.get_image_name(on_img)
    self.theme_images[on_name] = on_img

    # radio on/disabled
    _on_dis = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(_on_dis)
    if colorname == LIGHT and self.is_light_theme:
        draw.ellipse(xy=[1, 1, 133, 133], outline=off_border, width=6)
    else:
        draw.ellipse(xy=[1, 1, 133, 133], fill=disabled)
    draw.ellipse([40, 40, 94, 94], fill=off_fill)
    on_dis_img = ImageTk.PhotoImage(_on_dis.resize(size, Resampling.LANCZOS))
    on_disabled_name = util.get_image_name(on_dis_img)
    self.theme_images[on_disabled_name] = on_dis_img

    # radio disabled
    _disabled = Image.new("RGBA", (134, 134))
    draw = ImageDraw.Draw(_disabled)
    draw.ellipse(
        xy=[1, 1, 133, 133], outline=disabled, width=3, fill=off_fill
    )
    disabled_img = ImageTk.PhotoImage(
        _disabled.resize(size, Resampling.LANCZOS)
    )
    disabled_name = util.get_image_name(disabled_img)
    self.theme_images[disabled_name] = disabled_img

    return off_name, on_name, disabled_name, on_disabled_name

create_radiobutton_style(colorname=DEFAULT)

Create a style for the ttk.Radiobutton widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
def create_radiobutton_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Radiobutton widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """

    STYLE = "TRadiobutton"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        colorname = PRIMARY
    else:
        ttkstyle = f"{colorname}.{STYLE}"

    # ( off, on, disabled )
    images = self.create_radiobutton_assets(colorname)
    width = self.scale_size(20)
    borderpad = self.scale_size(4)
    self.style.element_create(
        f"{ttkstyle}.indicator",
        "image",
        images[1],
        ("disabled selected", images[3]),
        ("disabled", images[2]),
        ("!selected", images[0]),
        width=width,
        border=borderpad,
        sticky=tk.W,
    )
    self.style.map(ttkstyle, foreground=[("disabled", disabled_fg)])
    self.style._build_configure(ttkstyle)
    self.style.layout(
        ttkstyle,
        [
            (
                "Radiobutton.padding",
                {
                    "children": [
                        (
                            f"{ttkstyle}.indicator",
                            {"side": tk.LEFT, "sticky": ""},
                        ),
                        (
                            "Radiobutton.focus",
                            {
                                "children": [
                                    (
                                        "Radiobutton.label",
                                        {"sticky": tk.NSEW},
                                    )
                                ],
                                "side": tk.LEFT,
                                "sticky": "",
                            },
                        ),
                    ],
                    "sticky": tk.NSEW,
                },
            )
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_round_scrollbar_assets(thumbcolor, pressed, active)

Create image assets to be used when building the round scrollbar style.

Parameters:

thumbcolor (str):
    The color value of the thumb in normal state.

pressed (str):
    The color value to use when the thumb is pressed.

active (str):
    The color value to use when the thumb is active or
    hovered.
Source code in src/ttkbootstrap/style.py
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
def create_round_scrollbar_assets(self, thumbcolor, pressed, active):
    """Create image assets to be used when building the round
    scrollbar style.

    Parameters:

        thumbcolor (str):
            The color value of the thumb in normal state.

        pressed (str):
            The color value to use when the thumb is pressed.

        active (str):
            The color value to use when the thumb is active or
            hovered.
    """
    vsize = self.scale_size([9, 28])
    hsize = self.scale_size([28, 9])

    def rounded_rect(size, fill):
        x = size[0] * 10
        y = size[1] * 10
        img = Image.new("RGBA", (x, y))
        draw = ImageDraw.Draw(img)
        radius = min([x, y]) // 2
        draw.rounded_rectangle([0, 0, x - 1, y - 1], radius, fill)
        image = ImageTk.PhotoImage(img.resize(size, Resampling.BICUBIC))
        name = util.get_image_name(image)
        self.theme_images[name] = image
        return name

    # create images
    h_normal_img = rounded_rect(hsize, thumbcolor)
    h_pressed_img = rounded_rect(hsize, pressed)
    h_active_img = rounded_rect(hsize, active)

    v_normal_img = rounded_rect(vsize, thumbcolor)
    v_pressed_img = rounded_rect(vsize, pressed)
    v_active_img = rounded_rect(vsize, active)

    return (
        h_normal_img,
        h_pressed_img,
        h_active_img,
        v_normal_img,
        v_pressed_img,
        v_active_img,
    )

create_round_scrollbar_style(colorname=DEFAULT)

Create a round style for the ttk.Scrollbar widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_round_scrollbar_style(self, colorname=DEFAULT):
    """Create a round style for the ttk.Scrollbar widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TScrollbar"

    if any([colorname == DEFAULT, colorname == ""]):
        h_ttkstyle = f"Round.Horizontal.{STYLE}"
        v_ttkstyle = f"Round.Vertical.{STYLE}"

        if self.is_light_theme:
            background = self.colors.border
        else:
            background = self.colors.selectbg

    else:
        h_ttkstyle = f"{colorname}.Round.Horizontal.{STYLE}"
        v_ttkstyle = f"{colorname}.Round.Vertical.{STYLE}"
        background = self.colors.get(colorname)

    if self.is_light_theme:
        if colorname == LIGHT:
            troughcolor = self.colors.bg
        else:
            troughcolor = self.colors.light
    else:
        troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

    pressed = Colors.update_hsv(background, vd=-0.05)
    active = Colors.update_hsv(background, vd=0.05)

    scroll_images = self.create_round_scrollbar_assets(
        background, pressed, active
    )

    # horizontal scrollbar
    self.style._build_configure(
        h_ttkstyle,
        troughcolor=troughcolor,
        darkcolor=troughcolor,
        bordercolor=troughcolor,
        lightcolor=troughcolor,
        arrowcolor=background,
        arrowsize=self.scale_size(11),
        background=troughcolor,
        relief=tk.FLAT,
        borderwidth=0,
    )
    self.style.element_create(
        f"{h_ttkstyle}.thumb",
        "image",
        scroll_images[0],
        ("pressed", scroll_images[1]),
        ("active", scroll_images[2]),
        border=self.scale_size(9),
        padding=0,
        sticky=tk.EW,
    )
    self.style.layout(
        h_ttkstyle,
        [
            (
                "Horizontal.Scrollbar.trough",
                {
                    "sticky": "we",
                    "children": [
                        (
                            "Horizontal.Scrollbar.leftarrow",
                            {"side": "left", "sticky": ""},
                        ),
                        (
                            "Horizontal.Scrollbar.rightarrow",
                            {"side": "right", "sticky": ""},
                        ),
                        (
                            f"{h_ttkstyle}.thumb",
                            {"expand": "1", "sticky": "nswe"},
                        ),
                    ],
                },
            )
        ],
    )
    self.style._build_configure(h_ttkstyle, arrowcolor=background)
    self.style.map(
        h_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
    )

    # vertical scrollbar
    self.style._build_configure(
        v_ttkstyle,
        troughcolor=troughcolor,
        darkcolor=troughcolor,
        bordercolor=troughcolor,
        lightcolor=troughcolor,
        arrowcolor=background,
        arrowsize=self.scale_size(11),
        background=troughcolor,
        relief=tk.FLAT,
    )
    self.style.element_create(
        f"{v_ttkstyle}.thumb",
        "image",
        scroll_images[3],
        ("pressed", scroll_images[4]),
        ("active", scroll_images[5]),
        border=self.scale_size(9),
        padding=0,
        sticky=tk.NS,
    )
    self.style.layout(
        v_ttkstyle,
        [
            (
                "Vertical.Scrollbar.trough",
                {
                    "sticky": "ns",
                    "children": [
                        (
                            "Vertical.Scrollbar.uparrow",
                            {"side": "top", "sticky": ""},
                        ),
                        (
                            "Vertical.Scrollbar.downarrow",
                            {"side": "bottom", "sticky": ""},
                        ),
                        (
                            f"{v_ttkstyle}.thumb",
                            {"expand": "1", "sticky": "nswe"},
                        ),
                    ],
                },
            )
        ],
    )
    self.style._build_configure(v_ttkstyle, arrowcolor=background)
    self.style.map(
        v_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
    )

    # register ttkstyles
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_round_toggle_assets(colorname=DEFAULT)

Create image assets for the round toggle style.

Parameters:

colorname (str):
    The color label assigned to the colors property.

Returns:

tuple[str]:
    A tuple of PhotoImage names.
Source code in src/ttkbootstrap/style.py
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
def create_round_toggle_assets(self, colorname=DEFAULT):
    """Create image assets for the round toggle style.

    Parameters:

        colorname (str):
            The color label assigned to the colors property.

    Returns:

        tuple[str]:
            A tuple of PhotoImage names.
    """
    size = self.scale_size([24, 15])

    if any([colorname == DEFAULT, colorname == ""]):
        colorname = PRIMARY

    # set default style color values
    prime_color = self.colors.get(colorname)
    on_border = prime_color
    on_indicator = self.colors.selectfg
    on_fill = prime_color
    off_fill = self.colors.bg

    disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)
    off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
    off_indicator = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)

    # override defaults for light and dark colors
    if colorname == LIGHT:
        on_border = self.colors.dark
        on_indicator = on_border
    elif colorname == DARK:
        on_border = self.colors.light
        on_indicator = on_border

    # toggle off
    _off = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(_off)
    draw.rounded_rectangle(
        xy=[1, 1, 225, 129],
        radius=(128 / 2),
        outline=off_border,
        width=6,
        fill=off_fill,
    )
    draw.ellipse([20, 18, 112, 110], fill=off_indicator)
    off_img = ImageTk.PhotoImage(_off.resize(size, Resampling.LANCZOS))
    off_name = util.get_image_name(off_img)
    self.theme_images[off_name] = off_img

    # toggle on
    _on = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(_on)
    draw.rounded_rectangle(
        xy=[1, 1, 225, 129],
        radius=(128 / 2),
        outline=on_border,
        width=6,
        fill=on_fill,
    )
    draw.ellipse([20, 18, 112, 110], fill=on_indicator)
    _on = _on.transpose(Transpose.ROTATE_180)
    on_img = ImageTk.PhotoImage(_on.resize(size, Resampling.LANCZOS))
    on_name = util.get_image_name(on_img)
    self.theme_images[on_name] = on_img

    # toggle on / disabled
    _on_disabled = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(_on_disabled)
    draw.rounded_rectangle(
        xy=[1, 1, 225, 129],
        radius=(128 / 2),
        outline=disabled_fg,
        width=6,
        fill=off_fill,
    )
    draw.ellipse([20, 18, 112, 110], fill=disabled_fg)
    _on_disabled = _on_disabled.transpose(Transpose.ROTATE_180)
    on_dis_img = ImageTk.PhotoImage(_on_disabled.resize(size, Resampling.LANCZOS))
    on_disabled_name = util.get_image_name(on_dis_img)
    self.theme_images[on_disabled_name] = on_dis_img

    # toggle disabled
    _disabled = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(_disabled)
    draw.rounded_rectangle(
        xy=[1, 1, 225, 129], radius=(128 / 2), outline=disabled_fg, width=6
    )
    draw.ellipse([20, 18, 112, 110], fill=disabled_fg)
    disabled_img = ImageTk.PhotoImage(
        _disabled.resize(size, Resampling.LANCZOS)
    )
    disabled_name = util.get_image_name(disabled_img)
    self.theme_images[disabled_name] = disabled_img

    return off_name, on_name, disabled_name, on_disabled_name

create_round_toggle_style(colorname=DEFAULT)

Create a round toggle style for the ttk.Checkbutton widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
def create_round_toggle_style(self, colorname=DEFAULT):
    """Create a round toggle style for the ttk.Checkbutton widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Round.Toggle"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        colorname = PRIMARY
    else:
        ttkstyle = f"{colorname}.{STYLE}"

    # ( off, on, disabled )
    images = self.create_round_toggle_assets(colorname)

    try:
        width = self.scale_size(28)
        borderpad = self.scale_size(4)
        self.style.element_create(
            f"{ttkstyle}.indicator",
            "image",
            images[1],
            ("disabled selected", images[3]),
            ("disabled", images[2]),
            ("!selected", images[0]),
            width=width,
            border=borderpad,
            sticky=tk.W,
        )
    except:
        """This method is used as the default Toggle style, so it
        is neccessary to catch Tcl Errors when it tries to create
        and element that was already created by the Toggle or
        Round Toggle style"""
        pass

    self.style._build_configure(
        ttkstyle,
        relief=tk.FLAT,
        borderwidth=0,
        padding=0,
        foreground=self.colors.fg,
        background=self.colors.bg,
    )
    self.style.map(
        ttkstyle,
        foreground=[("disabled", disabled_fg)],
        background=[("selected", self.colors.bg)],
    )
    self.style.layout(
        ttkstyle,
        [
            (
                "Toolbutton.border",
                {
                    "sticky": tk.NSEW,
                    "children": [
                        (
                            "Toolbutton.padding",
                            {
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        f"{ttkstyle}.indicator",
                                        {"side": tk.LEFT},
                                    ),
                                    (
                                        "Toolbutton.label",
                                        {"side": tk.LEFT},
                                    ),
                                ],
                            },
                        )
                    ],
                },
            )
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_scale_assets(colorname=DEFAULT, size=14)

Create the assets used for the ttk.Scale widget.

The slider handle is automatically adjusted to fit the screen resolution.

Parameters:

colorname (str):
    The color label.

size (int):
    The size diameter of the slider circle; default=16.

Returns:

tuple[str]:
    A tuple of PhotoImage names to be used in the image
    layout when building the style.
Source code in src/ttkbootstrap/style.py
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
def create_scale_assets(self, colorname=DEFAULT, size=14):
    """Create the assets used for the ttk.Scale widget.

    The slider handle is automatically adjusted to fit the
    screen resolution.

    Parameters:

        colorname (str):
            The color label.

        size (int):
            The size diameter of the slider circle; default=16.

    Returns:

        tuple[str]:
            A tuple of PhotoImage names to be used in the image
            layout when building the style.
    """
    size = self.scale_size(size)
    if self.is_light_theme:
        disabled_color = self.colors.border
        if colorname == LIGHT:
            track_color = self.colors.bg
        else:
            track_color = self.colors.light
    else:
        disabled_color = self.colors.selectbg
        track_color = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

    if any([colorname == DEFAULT, colorname == ""]):
        normal_color = self.colors.primary
    else:
        normal_color = self.colors.get(colorname)

    pressed_color = Colors.update_hsv(normal_color, vd=-0.1)
    hover_color = Colors.update_hsv(normal_color, vd=0.1)

    # normal state
    _normal = Image.new("RGBA", (100, 100))
    draw = ImageDraw.Draw(_normal)
    draw.ellipse((0, 0, 95, 95), fill=normal_color)
    normal_img = ImageTk.PhotoImage(
        _normal.resize((size, size), Resampling.LANCZOS)
    )
    normal_name = util.get_image_name(normal_img)
    self.theme_images[normal_name] = normal_img

    # pressed state
    _pressed = Image.new("RGBA", (100, 100))
    draw = ImageDraw.Draw(_pressed)
    draw.ellipse((0, 0, 95, 95), fill=pressed_color)
    pressed_img = ImageTk.PhotoImage(
        _pressed.resize((size, size), Resampling.LANCZOS)
    )
    pressed_name = util.get_image_name(pressed_img)
    self.theme_images[pressed_name] = pressed_img

    # hover state
    _hover = Image.new("RGBA", (100, 100))
    draw = ImageDraw.Draw(_hover)
    draw.ellipse((0, 0, 95, 95), fill=hover_color)
    hover_img = ImageTk.PhotoImage(
        _hover.resize((size, size), Resampling.LANCZOS)
    )
    hover_name = util.get_image_name(hover_img)
    self.theme_images[hover_name] = hover_img

    # disabled state
    _disabled = Image.new("RGBA", (100, 100))
    draw = ImageDraw.Draw(_disabled)
    draw.ellipse((0, 0, 95, 95), fill=disabled_color)
    disabled_img = ImageTk.PhotoImage(
        _disabled.resize((size, size), Resampling.LANCZOS)
    )
    disabled_name = util.get_image_name(disabled_img)
    self.theme_images[disabled_name] = disabled_img

    # vertical track
    h_track_img = ImageTk.PhotoImage(
        Image.new("RGB", self.scale_size((40, 5)), track_color)
    )
    h_track_name = util.get_image_name(h_track_img)
    self.theme_images[h_track_name] = h_track_img

    # horizontal track
    v_track_img = ImageTk.PhotoImage(
        Image.new("RGB", self.scale_size((5, 40)), track_color)
    )
    v_track_name = util.get_image_name(v_track_img)
    self.theme_images[v_track_name] = v_track_img

    return (
        normal_name,
        pressed_name,
        hover_name,
        disabled_name,
        h_track_name,
        v_track_name,
    )

create_scale_style(colorname=DEFAULT)

Create a style for the ttk.Scale widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_scale_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Scale widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TScale"

    if any([colorname == DEFAULT, colorname == ""]):
        h_ttkstyle = f"Horizontal.{STYLE}"
        v_ttkstyle = f"Vertical.{STYLE}"
    else:
        h_ttkstyle = f"{colorname}.Horizontal.{STYLE}"
        v_ttkstyle = f"{colorname}.Vertical.{STYLE}"

    # ( normal, pressed, hover, disabled, htrack, vtrack )
    images = self.create_scale_assets(colorname)

    # horizontal scale
    h_element = h_ttkstyle.replace(".TS", ".S")
    self.style.element_create(
        f"{h_element}.slider",
        "image",
        images[0],
        ("disabled", images[3]),
        ("pressed", images[1]),
        ("hover", images[2]),
    )
    self.style.element_create(f"{h_element}.track", "image", images[4])
    self.style.layout(
        h_ttkstyle,
        [
            (
                f"{h_element}.focus",
                {
                    "expand": "1",
                    "sticky": tk.NSEW,
                    "children": [
                        (f"{h_element}.track", {"sticky": tk.EW}),
                        (
                            f"{h_element}.slider",
                            {"side": tk.LEFT, "sticky": ""},
                        ),
                    ],
                },
            )
        ],
    )
    # vertical scale
    v_element = v_ttkstyle.replace(".TS", ".S")
    self.style.element_create(
        f"{v_element}.slider",
        "image",
        images[0],
        ("disabled", images[3]),
        ("pressed", images[1]),
        ("hover", images[2]),
    )
    self.style.element_create(f"{v_element}.track", "image", images[5])
    self.style.layout(
        v_ttkstyle,
        [
            (
                f"{v_element}.focus",
                {
                    "expand": "1",
                    "sticky": tk.NSEW,
                    "children": [
                        (f"{v_element}.track", {"sticky": tk.NS}),
                        (
                            f"{v_element}.slider",
                            {"side": tk.TOP, "sticky": ""},
                        ),
                    ],
                },
            )
        ],
    )
    # register ttkstyles
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_scrollbar_assets(thumbcolor, pressed, active)

Create the image assets used to build the standard scrollbar style.

Parameters:

thumbcolor (str):
    The primary color value used to color the thumb.

pressed (str):
    The color value to use when the thumb is pressed.

active (str):
    The color value to use when the thumb is active or
    hovered.
Source code in src/ttkbootstrap/style.py
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
def create_scrollbar_assets(self, thumbcolor, pressed, active):
    """Create the image assets used to build the standard scrollbar
    style.

    Parameters:

        thumbcolor (str):
            The primary color value used to color the thumb.

        pressed (str):
            The color value to use when the thumb is pressed.

        active (str):
            The color value to use when the thumb is active or
            hovered.
    """
    vsize = self.scale_size([9, 28])
    hsize = self.scale_size([28, 9])

    def draw_rect(size, fill):
        x = size[0] * 10
        y = size[1] * 10
        img = Image.new("RGBA", (x, y), fill)
        image = ImageTk.PhotoImage(img.resize(size), Resampling.BICUBIC)
        name = util.get_image_name(image)
        self.theme_images[name] = image
        return name

    # create images
    h_normal_img = draw_rect(hsize, thumbcolor)
    h_pressed_img = draw_rect(hsize, pressed)
    h_active_img = draw_rect(hsize, active)

    v_normal_img = draw_rect(vsize, thumbcolor)
    v_pressed_img = draw_rect(vsize, pressed)
    v_active_img = draw_rect(vsize, active)

    return (
        h_normal_img,
        h_pressed_img,
        h_active_img,
        v_normal_img,
        v_pressed_img,
        v_active_img,
    )

create_scrollbar_style(colorname=DEFAULT)

Create a standard style for the ttk.Scrollbar widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_scrollbar_style(self, colorname=DEFAULT):
    """Create a standard style for the ttk.Scrollbar widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TScrollbar"

    if any([colorname == DEFAULT, colorname == ""]):
        h_ttkstyle = f"Horizontal.{STYLE}"
        v_ttkstyle = f"Vertical.{STYLE}"

        if self.is_light_theme:
            background = self.colors.border
        else:
            background = self.colors.selectbg

    else:
        h_ttkstyle = f"{colorname}.Horizontal.{STYLE}"
        v_ttkstyle = f"{colorname}.Vertical.{STYLE}"
        background = self.colors.get(colorname)

    if self.is_light_theme:
        if colorname == LIGHT:
            troughcolor = self.colors.bg
        else:
            troughcolor = self.colors.light
    else:
        troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)

    pressed = Colors.update_hsv(background, vd=-0.05)
    active = Colors.update_hsv(background, vd=0.05)

    scroll_images = self.create_scrollbar_assets(
        background, pressed, active
    )

    # horizontal scrollbar
    self.style._build_configure(
        h_ttkstyle,
        troughcolor=troughcolor,
        darkcolor=troughcolor,
        bordercolor=troughcolor,
        lightcolor=troughcolor,
        arrowcolor=background,
        arrowsize=self.scale_size(11),
        background=troughcolor,
        relief=tk.FLAT,
        borderwidth=0,
    )
    self.style.element_create(
        f"{h_ttkstyle}.thumb",
        "image",
        scroll_images[0],
        ("pressed", scroll_images[1]),
        ("active", scroll_images[2]),
        border=(3, 0),
        sticky=tk.NSEW,
    )
    self.style.layout(
        h_ttkstyle,
        [
            (
                "Horizontal.Scrollbar.trough",
                {
                    "sticky": "we",
                    "children": [
                        (
                            "Horizontal.Scrollbar.leftarrow",
                            {"side": "left", "sticky": ""},
                        ),
                        (
                            "Horizontal.Scrollbar.rightarrow",
                            {"side": "right", "sticky": ""},
                        ),
                        (
                            f"{h_ttkstyle}.thumb",
                            {"expand": "1", "sticky": "nswe"},
                        ),
                    ],
                },
            )
        ],
    )
    self.style._build_configure(h_ttkstyle, arrowcolor=background)
    self.style.map(
        h_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
    )

    # vertical scrollbar
    self.style._build_configure(
        v_ttkstyle,
        troughcolor=troughcolor,
        darkcolor=troughcolor,
        bordercolor=troughcolor,
        lightcolor=troughcolor,
        arrowcolor=background,
        arrowsize=self.scale_size(11),
        background=troughcolor,
        relief=tk.FLAT,
        borderwidth=0,
    )
    self.style.element_create(
        f"{v_ttkstyle}.thumb",
        "image",
        scroll_images[3],
        ("pressed", scroll_images[4]),
        ("active", scroll_images[5]),
        border=(0, 3),
        sticky=tk.NSEW,
    )
    self.style.layout(
        v_ttkstyle,
        [
            (
                "Vertical.Scrollbar.trough",
                {
                    "sticky": "ns",
                    "children": [
                        (
                            "Vertical.Scrollbar.uparrow",
                            {"side": "top", "sticky": ""},
                        ),
                        (
                            "Vertical.Scrollbar.downarrow",
                            {"side": "bottom", "sticky": ""},
                        ),
                        (
                            f"{v_ttkstyle}.thumb",
                            {"expand": "1", "sticky": "nswe"},
                        ),
                    ],
                },
            )
        ],
    )
    self.style._build_configure(v_ttkstyle, arrowcolor=background)
    self.style.map(
        v_ttkstyle, arrowcolor=[("pressed", pressed), ("active", active)]
    )

    # register ttkstyles
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_separator_style(colorname=DEFAULT)

Create a style for the ttk.Separator widget.

Parameters:

colorname (str):
    The primary widget color.
Source code in src/ttkbootstrap/style.py
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
def create_separator_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Separator widget.

    Parameters:

        colorname (str):
            The primary widget color.
    """
    HSTYLE = "Horizontal.TSeparator"
    VSTYLE = "Vertical.TSeparator"

    hsize = [40, 1]
    vsize = [1, 40]

    # style colors
    if self.is_light_theme:
        default_color = self.colors.border
    else:
        default_color = self.colors.selectbg

    if any([colorname == DEFAULT, colorname == ""]):
        background = default_color
        h_ttkstyle = HSTYLE
        v_ttkstyle = VSTYLE
    else:
        background = self.colors.get(colorname)
        h_ttkstyle = f"{colorname}.{HSTYLE}"
        v_ttkstyle = f"{colorname}.{VSTYLE}"

    # horizontal separator
    h_element = h_ttkstyle.replace(".TS", ".S")
    h_img = ImageTk.PhotoImage(Image.new("RGB", hsize, background))
    h_name = util.get_image_name(h_img)
    self.theme_images[h_name] = h_img

    self.style.element_create(f"{h_element}.separator", "image", h_name)
    self.style.layout(
        h_ttkstyle, [(f"{h_element}.separator", {"sticky": tk.EW})]
    )

    # vertical separator
    v_element = v_ttkstyle.replace(".TS", ".S")
    v_img = ImageTk.PhotoImage(Image.new("RGB", vsize, background))
    v_name = util.get_image_name(v_img)
    self.theme_images[v_name] = v_img
    self.style.element_create(f"{v_element}.separator", "image", v_name)
    self.style.layout(
        v_ttkstyle, [(f"{v_element}.separator", {"sticky": tk.NS})]
    )
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_simple_arrow_assets(arrowcolor, disabledcolor, activecolor, y_offset=0)

Create simple arrow assets (small triangles) that can be used for various widgets. Originally created to replace Combobox.downarrow to fix layout issues in python 3.13. Also used for the Spinbox widget.

Parameters:

Name Type Description Default
arrowcolor str

The color value to use as the arrow fill color.

required
disabledcolor str

A second color value to use when the arrow is disabled.

required
activecolor str

A third color value to use when the arrow has focus.

required
y_offset int

(optional) The vertical padding to apply to the arrow images (useful in spinnboxes).

0

Returns: A nested tuple containing the names of the created arrow images in the order (up, down, left, right) for each color.

Source code in src/ttkbootstrap/style.py
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
def create_simple_arrow_assets(self, arrowcolor: str, disabledcolor: str, activecolor: str, y_offset: int = 0):
    """
    Create simple arrow assets (small triangles) that can be used for various widgets.
    Originally created to replace Combobox.downarrow to fix layout issues in python 3.13.
    Also used for the Spinbox widget.

    Args:
        arrowcolor: The color value to use as the arrow fill color.
        disabledcolor: A second color value to use when the arrow is disabled.
        activecolor: A third color value to use when the arrow has focus.
        y_offset: (optional) The vertical padding to apply to the arrow images (useful in spinnboxes).
    Returns:
        A nested tuple containing the names of the created arrow images in the order (up, down, left, right)
        for each color.
    """

    def draw_simple_arrow(color: str, y_offset: int = 0):
        img = Image.new("RGBA", (13, 11))
        draw = ImageDraw.Draw(img)
        size = self.scale_size([13, 11])

        # Draw the arrow shape (triangle) pointing upwards, offset by the specified y_offset
        draw.polygon([(3, 6 + y_offset), (9, 6 + y_offset), (6, 3 + y_offset)], fill=color)

        img = img.resize(size, Resampling.BICUBIC)

        up_img = ImageTk.PhotoImage(img)
        up_name = util.get_image_name(up_img)
        self.theme_images[up_name] = up_img

        down_img = ImageTk.PhotoImage(img.rotate(180))
        down_name = util.get_image_name(down_img)
        self.theme_images[down_name] = down_img

        left_img = ImageTk.PhotoImage(img.rotate(90))
        left_name = util.get_image_name(left_img)
        self.theme_images[left_name] = left_img

        right_img = ImageTk.PhotoImage(img.rotate(-90))
        right_name = util.get_image_name(right_img)
        self.theme_images[right_name] = right_img

        return up_name, down_name, left_name, right_name

    normal_names = draw_simple_arrow(arrowcolor, y_offset=y_offset)
    pressed_names = draw_simple_arrow(disabledcolor, y_offset=y_offset)
    active_names = draw_simple_arrow(activecolor, y_offset=y_offset)

    return normal_names, pressed_names, active_names

create_sizegrip_assets(color)

Create image assets used to build the sizegrip style.

Parameters:

color (str):
    The color _value_ used to draw the image.

Returns:

str:
    The PhotoImage name.
Source code in src/ttkbootstrap/style.py
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
def create_sizegrip_assets(self, color):
    """Create image assets used to build the sizegrip style.

    Parameters:

        color (str):
            The color _value_ used to draw the image.

    Returns:

        str:
            The PhotoImage name.
    """

    box = self.scale_size(1)
    pad = box * 2
    chunk = box + pad  # 4

    w = chunk * 3 + pad  # 14
    h = chunk * 3 + pad  # 14

    size = [w, h]

    im = Image.new("RGBA", size)
    draw = ImageDraw.Draw(im)

    draw.rectangle((chunk * 2 + pad, pad, chunk * 3, chunk), fill=color)
    draw.rectangle(
        (chunk * 2 + pad, chunk + pad, chunk * 3, chunk * 2), fill=color
    )
    draw.rectangle(
        (chunk * 2 + pad, chunk * 2 + pad, chunk * 3, chunk * 3),
        fill=color,
    )

    draw.rectangle(
        (chunk + pad, chunk + pad, chunk * 2, chunk * 2), fill=color
    )
    draw.rectangle(
        (chunk + pad, chunk * 2 + pad, chunk * 2, chunk * 3), fill=color
    )

    draw.rectangle((pad, chunk * 2 + pad, chunk, chunk * 3), fill=color)

    _img = ImageTk.PhotoImage(im)
    _name = util.get_image_name(_img)
    self.theme_images[_name] = _img
    return _name

create_sizegrip_style(colorname=DEFAULT)

Create a style for the ttk.Sizegrip widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
def create_sizegrip_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Sizegrip widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TSizegrip"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE

        if self.is_light_theme:
            grip_color = self.colors.border
        else:
            grip_color = self.colors.inputbg
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        grip_color = self.colors.get(colorname)

    image = self.create_sizegrip_assets(grip_color)

    self.style.element_create(
        f"{ttkstyle}.Sizegrip.sizegrip", "image", image
    )
    self.style.layout(
        ttkstyle,
        [
            (
                f"{ttkstyle}.Sizegrip.sizegrip",
                {"side": tk.BOTTOM, "sticky": tk.SE},
            )
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_spinbox_style(colorname=DEFAULT)

Create a style for the ttk.Spinbox widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_spinbox_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Spinbox widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "TSpinbox"

    if self.is_light_theme:
        disabled_fg = self.colors.border
        bordercolor = self.colors.border
        readonly = self.colors.light
    else:
        disabled_fg = self.colors.selectbg
        bordercolor = self.colors.selectbg
        readonly = bordercolor

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        focuscolor = self.colors.primary
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        focuscolor = self.colors.get(colorname)

    if all([colorname, colorname != DEFAULT]):
        bordercolor = focuscolor

    if colorname == "light":
        arrowfocus = self.colors.fg
    else:
        arrowfocus = focuscolor

    element = ttkstyle.replace(".TS", ".S")
    arrow_images = self.create_simple_arrow_assets(
        self.colors.inputfg, disabled_fg, arrowfocus, y_offset=2
    )
    uparrow_image = arrow_images[0][0]
    uparrow_disabled_image = arrow_images[1][0]
    uparrow_focus_image = arrow_images[2][0]
    downarrow_image = arrow_images[0][1]
    downarrow_disabled_image = arrow_images[1][1]
    downarrow_focus_image = arrow_images[2][1]

    self.style.element_create(
        f"{element}.uparrow",
        "image",
        uparrow_image,
        ("disabled", uparrow_disabled_image),
        ("pressed !disabled", uparrow_focus_image),
        ("hover !disabled", uparrow_focus_image),
    )
    self.style.element_create(
        f"{element}.downarrow",
        "image",
        downarrow_image,
        ("disabled", downarrow_disabled_image),
        ("pressed !disabled", downarrow_focus_image),
        ("hover !disabled", downarrow_focus_image),
    )
    self.style.layout(
        ttkstyle,
        [
            (
                f"{element}.field",
                {
                    "side": tk.TOP,
                    "sticky": tk.EW,
                    "children": [
                        (
                            "null",
                            {
                                "side": tk.RIGHT,
                                "sticky": "",
                                "children": [
                                    (
                                        f"{element}.uparrow",
                                        {"side": tk.TOP, "sticky": tk.E},
                                    ),
                                    (
                                        f"{element}.downarrow",
                                        {
                                            "side": tk.BOTTOM,
                                            "sticky": tk.E,
                                        },
                                    ),
                                ],
                            },
                        ),
                        (
                            f"{element}.padding",
                            {
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        f"{element}.textarea",
                                        {"sticky": tk.NSEW},
                                    )
                                ],
                            },
                        ),
                    ],
                },
            )
        ],
    )
    self.style._build_configure(
        ttkstyle,
        bordercolor=bordercolor,
        darkcolor=self.colors.inputbg,
        lightcolor=self.colors.inputbg,
        fieldbackground=self.colors.inputbg,
        foreground=self.colors.inputfg,
        borderwidth=0,
        background=self.colors.inputbg,
        relief=tk.FLAT,
        insertcolor=self.colors.inputfg,
        padding=(10, 5),
    )
    self.style.map(
        ttkstyle,
        foreground=[("disabled", disabled_fg)],
        fieldbackground=[("readonly", readonly)],
        background=[("readonly", readonly)],
        lightcolor=[
            ("focus invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("readonly", readonly),
        ],
        darkcolor=[
            ("focus invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("readonly", readonly),
        ],
        bordercolor=[
            ("invalid", self.colors.danger),
            ("focus !disabled", focuscolor),
            ("hover !disabled", focuscolor),
        ],
    )
    # register ttkstyles
    self.style._register_ttkstyle(ttkstyle)

create_square_toggle_assets(colorname=DEFAULT)

Create the image assets used to build a square toggle style.

Parameters:

colorname (str):
    The color label used to style the widget.

Returns:

tuple[str]:
    A tuple of PhotoImage names.
Source code in src/ttkbootstrap/style.py
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
def create_square_toggle_assets(self, colorname=DEFAULT):
    """Create the image assets used to build a square toggle
    style.

    Parameters:

        colorname (str):
            The color label used to style the widget.

    Returns:

        tuple[str]:
            A tuple of PhotoImage names.
    """
    size = self.scale_size([24, 15])
    if any([colorname == DEFAULT, colorname == ""]):
        colorname = PRIMARY

    # set default style color values
    prime_color = self.colors.get(colorname)
    on_border = prime_color
    on_indicator = self.colors.selectfg
    on_fill = prime_color
    off_fill = self.colors.bg
    disabled_fg = Colors.make_transparent(0.3, self.colors.fg, self.colors.bg)
    off_border = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)
    off_indicator = Colors.make_transparent(0.4, self.colors.fg, self.colors.bg)

    # override defaults for light and dark colors
    if colorname == LIGHT:
        on_border = self.colors.dark
        on_indicator = on_border
    elif colorname == DARK:
        on_border = self.colors.light
        on_indicator = on_border

    # toggle off
    _off = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(_off)
    draw.rectangle(
        xy=[1, 1, 225, 129], outline=off_border, width=6, fill=off_fill
    )
    draw.rectangle([18, 18, 110, 110], fill=off_indicator)

    off_img = ImageTk.PhotoImage(_off.resize(size, Resampling.LANCZOS))
    off_name = util.get_image_name(off_img)
    self.theme_images[off_name] = off_img

    # toggle on
    toggle_on = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(toggle_on)
    draw.rectangle(
        xy=[1, 1, 225, 129], outline=on_border, width=6, fill=on_fill
    )
    draw.rectangle([18, 18, 110, 110], fill=on_indicator)
    _on = toggle_on.transpose(Transpose.ROTATE_180)
    on_img = ImageTk.PhotoImage(_on.resize(size, Resampling.LANCZOS))
    on_name = util.get_image_name(on_img)
    self.theme_images[on_name] = on_img

    # toggle disabled
    _disabled = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(_disabled)
    draw.rectangle([1, 1, 225, 129], outline=disabled_fg, width=6)
    draw.rectangle([18, 18, 110, 110], fill=disabled_fg)
    disabled_img = ImageTk.PhotoImage(
        _disabled.resize(size, Resampling.LANCZOS)
    )
    disabled_name = util.get_image_name(disabled_img)
    self.theme_images[disabled_name] = disabled_img

    # toggle on / disabled
    toggle_on_disabled = Image.new("RGBA", (226, 130))
    draw = ImageDraw.Draw(toggle_on_disabled)
    draw.rectangle(
        xy=[1, 1, 225, 129], outline=disabled_fg, width=6, fill=off_fill
    )
    draw.rectangle([18, 18, 110, 110], fill=disabled_fg)
    _on_disabled = toggle_on_disabled.transpose(Transpose.ROTATE_180)
    on_dis_img = ImageTk.PhotoImage(_on_disabled.resize(size, Resampling.LANCZOS))
    on_disabled_name = util.get_image_name(on_dis_img)
    self.theme_images[on_disabled_name] = on_dis_img

    return off_name, on_name, disabled_name, on_disabled_name

create_square_toggle_style(colorname=DEFAULT)

Create a square toggle style for the ttk.Checkbutton widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
def create_square_toggle_style(self, colorname=DEFAULT):
    """Create a square toggle style for the ttk.Checkbutton widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """

    STYLE = "Square.Toggle"

    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
    else:
        ttkstyle = f"{colorname}.{STYLE}"

    # ( off, on, disabled )
    images = self.create_square_toggle_assets(colorname)

    width = self.scale_size(28)
    borderpad = self.scale_size(4)

    self.style.element_create(
        f"{ttkstyle}.indicator",
        "image",
        images[1],
        ("disabled selected", images[3]),
        ("disabled", images[2]),
        ("!selected", images[0]),
        width=width,
        border=borderpad,
        sticky=tk.W,
    )
    self.style.layout(
        ttkstyle,
        [
            (
                "Toolbutton.border",
                {
                    "sticky": tk.NSEW,
                    "children": [
                        (
                            "Toolbutton.padding",
                            {
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        f"{ttkstyle}.indicator",
                                        {"side": tk.LEFT},
                                    ),
                                    (
                                        "Toolbutton.label",
                                        {"side": tk.LEFT},
                                    ),
                                ],
                            },
                        )
                    ],
                },
            )
        ],
    )
    self.style._build_configure(
        ttkstyle, relief=tk.FLAT, borderwidth=0, foreground=self.colors.fg
    )
    self.style.map(
        ttkstyle,
        foreground=[("disabled", disabled_fg)],
        background=[
            ("selected", self.colors.bg),
            ("!selected", self.colors.bg),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_striped_progressbar_assets(thickness, colorname=DEFAULT)

Create the striped progressbar image and return as a PhotoImage

Parameters:

colorname (str):
    The color label used to style the widget.

Returns:

tuple[str]:
    A list of photoimage names.
Source code in src/ttkbootstrap/style.py
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
def create_striped_progressbar_assets(self, thickness, colorname=DEFAULT):
    """Create the striped progressbar image and return as a
    `PhotoImage`

    Parameters:

        colorname (str):
            The color label used to style the widget.

    Returns:

        tuple[str]:
            A list of photoimage names.
    """
    if any([colorname == DEFAULT, colorname == ""]):
        barcolor = self.colors.primary
    else:
        barcolor = self.colors.get(colorname)

    # calculate value of the light color
    brightness = Colors.rgb_to_hsv(*Colors.hex_to_rgb(barcolor))[2]
    if brightness < 0.4:
        value_delta = 0.3
    elif brightness > 0.8:
        value_delta = 0
    else:
        value_delta = 0.1

    barcolor_light = Colors.update_hsv(barcolor, sd=-0.2, vd=value_delta)

    # horizontal progressbar
    img = Image.new("RGBA", (100, 100), barcolor_light)
    draw = ImageDraw.Draw(img)
    draw.polygon(
        xy=[(0, 0), (48, 0), (100, 52), (100, 100)],
        fill=barcolor,
    )
    draw.polygon(xy=[(0, 52), (48, 100), (0, 100)], fill=barcolor)

    _resized = img.resize((thickness, thickness), Resampling.LANCZOS)
    h_img = ImageTk.PhotoImage(_resized)
    h_name = h_img._PhotoImage__photo.name
    v_img = ImageTk.PhotoImage(_resized.rotate(90))
    v_name = v_img._PhotoImage__photo.name

    self.theme_images[h_name] = h_img
    self.theme_images[v_name] = v_img
    return h_name, v_name

create_striped_progressbar_style(colorname=DEFAULT)

Create a striped style for the ttk.Progressbar widget.

Parameters:

colorname (str):
    The primary widget color label.
Source code in src/ttkbootstrap/style.py
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
def create_striped_progressbar_style(self, colorname=DEFAULT):
    """Create a striped style for the ttk.Progressbar widget.

    Parameters:

        colorname (str):
            The primary widget color label.
    """
    HSTYLE = "Striped.Horizontal.TProgressbar"
    VSTYLE = "Striped.Vertical.TProgressbar"

    thickness = self.scale_size(12)

    if any([colorname == DEFAULT, colorname == ""]):
        h_ttkstyle = HSTYLE
        v_ttkstyle = VSTYLE
    else:
        h_ttkstyle = f"{colorname}.{HSTYLE}"
        v_ttkstyle = f"{colorname}.{VSTYLE}"

    if self.is_light_theme:
        if colorname == LIGHT:
            troughcolor = self.colors.bg
            bordercolor = self.colors.light
        else:
            troughcolor = self.colors.light
            bordercolor = troughcolor
    else:
        troughcolor = Colors.update_hsv(self.colors.selectbg, vd=-0.2)
        bordercolor = troughcolor

    # ( horizontal, vertical )
    images = self.create_striped_progressbar_assets(thickness, colorname)

    # horizontal progressbar
    h_element = h_ttkstyle.replace(".TP", ".P")
    self.style.element_create(
        f"{h_element}.pbar",
        "image",
        images[0],
        width=thickness,
        sticky=tk.EW,
    )
    self.style.layout(
        h_ttkstyle,
        [
            (
                f"{h_element}.trough",
                {
                    "sticky": tk.NSEW,
                    "children": [
                        (
                            f"{h_element}.pbar",
                            {"side": tk.LEFT, "sticky": tk.NS},
                        )
                    ],
                },
            )
        ],
    )
    self.style._build_configure(
        h_ttkstyle,
        troughcolor=troughcolor,
        thickness=thickness,
        bordercolor=bordercolor,
        borderwidth=1,
    )

    # vertical progressbar
    v_element = v_ttkstyle.replace(".TP", ".P")
    self.style.element_create(
        f"{v_element}.pbar",
        "image",
        images[1],
        width=thickness,
        sticky=tk.NS,
    )
    self.style.layout(
        v_ttkstyle,
        [
            (
                f"{v_element}.trough",
                {
                    "sticky": tk.NSEW,
                    "children": [
                        (
                            f"{v_element}.pbar",
                            {"side": tk.BOTTOM, "sticky": tk.EW},
                        )
                    ],
                },
            )
        ],
    )
    self.style._build_configure(
        v_ttkstyle,
        troughcolor=troughcolor,
        bordercolor=bordercolor,
        thickness=thickness,
        borderwidth=1,
    )
    self.style._register_ttkstyle(h_ttkstyle)
    self.style._register_ttkstyle(v_ttkstyle)

create_table_treeview_style(colorname=DEFAULT)

Create a style for the Tableview widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_table_treeview_style(self, colorname=DEFAULT):
    """Create a style for the Tableview widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Table.Treeview"

    f = font.nametofont("TkDefaultFont")
    rowheight = f.metrics()["linespace"]

    if self.is_light_theme:
        disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.2)
        bordercolor = self.colors.border
        hover = Colors.update_hsv(self.colors.light, vd=-0.1)
    else:
        disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.3)
        bordercolor = self.colors.selectbg
        hover = Colors.update_hsv(self.colors.dark, vd=0.1)

    if any([colorname == DEFAULT, colorname == ""]):
        background = self.colors.inputbg
        foreground = self.colors.inputfg
        body_style = STYLE
        header_style = f"{STYLE}.Heading"
    elif colorname == LIGHT and self.is_light_theme:
        background = self.colors.get(colorname)
        foreground = self.colors.fg
        body_style = f"{colorname}.{STYLE}"
        header_style = f"{colorname}.{STYLE}.Heading"
        hover = Colors.update_hsv(background, vd=-0.1)
    else:
        background = self.colors.get(colorname)
        foreground = self.colors.selectfg
        body_style = f"{colorname}.{STYLE}"
        header_style = f"{colorname}.{STYLE}.Heading"
        hover = Colors.update_hsv(background, vd=0.1)

    # treeview header
    self.style._build_configure(
        header_style,
        background=background,
        foreground=foreground,
        relief=RAISED,
        borderwidth=1,
        darkcolor=background,
        bordercolor=bordercolor,
        lightcolor=background,
        padding=5,
    )
    self.style.map(
        header_style,
        foreground=[("disabled", disabled_fg)],
        background=[
            ("active !disabled", hover),
        ],
        darkcolor=[
            ("active !disabled", hover),
        ],
        lightcolor=[
            ("active !disabled", hover),
        ],
    )
    self.style._build_configure(
        body_style,
        background=self.colors.inputbg,
        fieldbackground=self.colors.inputbg,
        foreground=self.colors.inputfg,
        bordercolor=bordercolor,
        lightcolor=self.colors.inputbg,
        darkcolor=self.colors.inputbg,
        borderwidth=2,
        padding=0,
        rowheight=rowheight,
        relief=tk.RAISED,
    )
    self.style.map(
        body_style,
        background=[("selected", self.colors.selectbg)],
        foreground=[
            ("disabled", disabled_fg),
            ("selected", self.colors.selectfg),
        ],
    )
    self.style.layout(
        body_style,
        [
            (
                "Button.border",
                {
                    "sticky": tk.NSEW,
                    "border": "1",
                    "children": [
                        (
                            "Treeview.padding",
                            {
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        "Treeview.treearea",
                                        {"sticky": tk.NSEW},
                                    )
                                ],
                            },
                        )
                    ],
                },
            )
        ],
    )
    # register ttkstyles
    self.style._register_ttkstyle(body_style)

create_theme()

Create and style a new ttk theme. A wrapper around internal style methods.

Source code in src/ttkbootstrap/style.py
1344
1345
1346
1347
1348
1349
1350
def create_theme(self):
    """Create and style a new ttk theme. A wrapper around internal
    style methods.
    """
    self.style.theme_create(self.theme.name, TTK_CLAM)
    ttk.Style.theme_use(self.style, self.theme.name)
    self.update_ttk_theme_settings()

create_toggle_style(colorname=DEFAULT)

Create a round toggle style for the ttk.Checkbutton widget.

Parameters:

colorname (str):
Source code in src/ttkbootstrap/style.py
3308
3309
3310
3311
3312
3313
3314
3315
def create_toggle_style(self, colorname=DEFAULT):
    """Create a round toggle style for the ttk.Checkbutton widget.

    Parameters:

        colorname (str):
    """
    self.create_round_toggle_style(colorname)

create_toolbutton_style(colorname=DEFAULT)

Create a solid toolbutton style for the ttk.Checkbutton and ttk.Radiobutton widgets.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
def create_toolbutton_style(self, colorname=DEFAULT):
    """Create a solid toolbutton style for the ttk.Checkbutton
    and ttk.Radiobutton widgets.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Toolbutton"

    if any([colorname == DEFAULT, colorname == ""]):
        ttkstyle = STYLE
        toggle_on = self.colors.primary
    else:
        ttkstyle = f"{colorname}.{STYLE}"
        toggle_on = self.colors.get(colorname)

    foreground = self.colors.get_foreground(colorname)

    if self.is_light_theme:
        toggle_off = self.colors.border
    else:
        toggle_off = self.colors.selectbg

    disabled_bg = Colors.make_transparent(0.10, self.colors.fg, self.colors.bg)
    disabled_fg = Colors.make_transparent(0.30, self.colors.fg, self.colors.bg)

    self.style._build_configure(
        ttkstyle,
        foreground=self.colors.selectfg,
        background=toggle_off,
        bordercolor=toggle_off,
        darkcolor=toggle_off,
        lightcolor=toggle_off,
        relief=tk.RAISED,
        focusthickness=1,
        focuscolor=foreground,
        padding=(10, 5),
        anchor=tk.CENTER,
    )
    self.style.map(
        ttkstyle,
        foreground=[
            ("disabled", disabled_fg),
            ("hover", foreground),
            ("selected", foreground),
        ],
        focuscolor=[
            ("disabled", disabled_fg),
            ("hover", foreground),
            ("selected", foreground),
        ],
        background=[
            ("disabled", disabled_bg),
            ("pressed !disabled", toggle_on),
            ("selected !disabled", toggle_on),
            ("hover !disabled", toggle_on),
        ],
        bordercolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", toggle_on),
            ("selected !disabled", toggle_on),
            ("hover !disabled", toggle_on),
        ],
        darkcolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", toggle_on),
            ("selected !disabled", toggle_on),
            ("hover !disabled", toggle_on),
        ],
        lightcolor=[
            ("disabled", disabled_bg),
            ("pressed !disabled", toggle_on),
            ("selected !disabled", toggle_on),
            ("hover !disabled", toggle_on),
        ],
    )
    # register ttkstyle
    self.style._register_ttkstyle(ttkstyle)

create_treeview_style(colorname=DEFAULT)

Create a style for the ttk.Treeview widget.

Parameters:

colorname (str):
    The color label used to style the widget.
Source code in src/ttkbootstrap/style.py
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
def create_treeview_style(self, colorname=DEFAULT):
    """Create a style for the ttk.Treeview widget.

    Parameters:

        colorname (str):
            The color label used to style the widget.
    """
    STYLE = "Treeview"

    f = font.nametofont("TkDefaultFont")
    rowheight = f.metrics()["linespace"]

    if self.is_light_theme:
        disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.2)
        bordercolor = self.colors.border
    else:
        disabled_fg = Colors.update_hsv(self.colors.inputbg, vd=-0.3)
        bordercolor = self.colors.selectbg

    if any([colorname == DEFAULT, colorname == ""]):
        background = self.colors.inputbg
        foreground = self.colors.inputfg
        body_style = STYLE
        header_style = f"{STYLE}.Heading"
        focuscolor = self.colors.primary
    elif colorname == LIGHT and self.is_light_theme:
        background = self.colors.get(colorname)
        foreground = self.colors.fg
        body_style = f"{colorname}.{STYLE}"
        header_style = f"{colorname}.{STYLE}.Heading"
        focuscolor = background
        bordercolor = focuscolor
    else:
        background = self.colors.get(colorname)
        foreground = self.colors.selectfg
        body_style = f"{colorname}.{STYLE}"
        header_style = f"{colorname}.{STYLE}.Heading"
        focuscolor = background
        bordercolor = focuscolor

    # treeview header
    self.style._build_configure(
        header_style,
        background=background,
        foreground=foreground,
        relief=tk.FLAT,
        padding=5,
    )
    self.style.map(
        header_style,
        foreground=[("disabled", disabled_fg)],
        bordercolor=[("focus !disabled", background)],
    )
    # treeview body
    self.style._build_configure(
        body_style,
        background=self.colors.inputbg,
        fieldbackground=self.colors.inputbg,
        foreground=self.colors.inputfg,
        bordercolor=bordercolor,
        lightcolor=self.colors.inputbg,
        darkcolor=self.colors.inputbg,
        borderwidth=2,
        padding=0,
        rowheight=rowheight,
        relief=tk.RAISED,
    )
    self.style.map(
        body_style,
        background=[("selected", self.colors.selectbg)],
        foreground=[
            ("disabled", disabled_fg),
            ("selected", self.colors.selectfg),
        ],
        bordercolor=[
            ("disabled", bordercolor),
            ("focus", focuscolor),
            ("pressed", focuscolor),
            ("hover", focuscolor),
        ],
        lightcolor=[("focus", focuscolor)],
        darkcolor=[("focus", focuscolor)],
    )
    self.style.layout(
        body_style,
        [
            (
                "Button.border",
                {
                    "sticky": tk.NSEW,
                    "border": "1",
                    "children": [
                        (
                            "Treeview.padding",
                            {
                                "sticky": tk.NSEW,
                                "children": [
                                    (
                                        "Treeview.treearea",
                                        {"sticky": tk.NSEW},
                                    )
                                ],
                            },
                        )
                    ],
                },
            )
        ],
    )

    try:
        self.style.element_create("Treeitem.indicator", "from", TTK_ALT)
    except:
        pass

    # register ttkstyles
    self.style._register_ttkstyle(body_style)

name_to_method(method_name) staticmethod

Get a method by name.

Parameters:

method_name (str):
    The name of the style builder method.

Returns:

Callable:
    The method that is named by `method_name`
Source code in src/ttkbootstrap/style.py
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
@staticmethod
def name_to_method(method_name):
    """Get a method by name.

    Parameters:

        method_name (str):
            The name of the style builder method.

    Returns:

        Callable:
            The method that is named by `method_name`
    """
    func = getattr(StyleBuilderTTK, method_name)
    return func

scale_size(size)

Scale the size of images and other assets based on the scaling factor of ttk to ensure that the image matches the screen resolution.

Parameters:

size (Union[int, List, Tuple]):
    A single integer or an iterable of integers
Source code in src/ttkbootstrap/style.py
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
def scale_size(self, size):
    """Scale the size of images and other assets based on the
    scaling factor of ttk to ensure that the image matches the
    screen resolution.

    Parameters:

        size (Union[int, List, Tuple]):
            A single integer or an iterable of integers
    """
    winsys = self.style.master.tk.call("tk", "windowingsystem")
    if winsys == "aqua":
        BASELINE = 1.000492368291482
    else:
        BASELINE = 1.33398982438864281
    scaling = self.style.master.tk.call("tk", "scaling")
    factor = scaling / BASELINE

    if isinstance(size, int) or isinstance(size, float):
        return ceil(size * factor)
    elif isinstance(size, tuple) or isinstance(size, list):
        return [ceil(x * factor) for x in size]

update_combobox_popdown_style(widget)

Update the legacy ttk.Combobox elements. This method is called every time the theme is changed in order to ensure that the legacy tkinter components embedded in this ttk widget are styled appropriate to the current theme.

The ttk.Combobox contains several elements that are not styled using the ttk theme engine. This includes the popdownwindow and the scrollbar. Both of these widgets are configured manually using calls to tcl/tk.

Parameters:

widget (ttk.Combobox):
    The combobox element to be updated.
Source code in src/ttkbootstrap/style.py
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
def update_combobox_popdown_style(self, widget):
    """Update the legacy ttk.Combobox elements. This method is
    called every time the theme is changed in order to ensure
    that the legacy tkinter components embedded in this ttk widget
    are styled appropriate to the current theme.

    The ttk.Combobox contains several elements that are not styled
    using the ttk theme engine. This includes the **popdownwindow**
    and the **scrollbar**. Both of these widgets are configured
    manually using calls to tcl/tk.

    Parameters:

        widget (ttk.Combobox):
            The combobox element to be updated.
    """
    if self.is_light_theme:
        bordercolor = self.colors.border
    else:
        bordercolor = self.colors.selectbg

    tk_settings = []
    tk_settings.extend(["-borderwidth", 2])
    tk_settings.extend(["-highlightthickness", 1])
    tk_settings.extend(["-highlightcolor", bordercolor])
    tk_settings.extend(["-background", self.colors.inputbg])
    tk_settings.extend(["-foreground", self.colors.inputfg])
    tk_settings.extend(["-selectbackground", self.colors.selectbg])
    tk_settings.extend(["-selectforeground", self.colors.selectfg])

    # set popdown style
    popdown = widget.tk.eval(f"ttk::combobox::PopdownWindow {widget}")
    widget.tk.call(f"{popdown}.f.l", "configure", *tk_settings)

    # set scrollbar style
    sb_style = "TCombobox.Vertical.TScrollbar"
    widget.tk.call(f"{popdown}.f.sb", "configure", "-style", sb_style)

update_ttk_theme_settings()

This method is called internally every time the theme is changed to update various components included in the body of the method.

Source code in src/ttkbootstrap/style.py
1352
1353
1354
1355
1356
def update_ttk_theme_settings(self):
    """This method is called internally every time the theme is
    changed to update various components included in the body of
    the method."""
    self.create_default_style()