Tkinter – assignment of binds via loop doesn’t work

I’ve tried to modify my code and make the assignments of binding events and shortcut to function via loop.

it work by having a master dictionary (not necessary, just for “shortcut modes” preposes) and a sub-dictionary with the key as the event and the value as the function.

there is also some conditions for what to bind, if the event needs double chevrons and lastly if it’s custom one that ends with a alphabetical character – make it bind event both with that character upper and lower.

this is the function:

from large_variables import * # this is where we get the the characters_str - a list of upper alphabetic characters
from tkinter import *

class Window(Tk):
    def __init__(self):
        super().__init__()
        ....
        self.binds('initial')

    def binds(self, mode : str):
    # modes dicts
        initial_dict = {'Modified' : self.status, 'Cut' : lambda event: self.cut(True), 'Copy' : self.copy(True), 'Control-Key-a' : self.select_all,
                        'Control-Key-l' : self.align_text, 'Control-Key-e' : lambda: self.align_text('center'), 'Control-Key-r' : lambda: self.align_text('right'),
                        'Control-Key-Delete' : self.clear, 'Alt-F4' : self.exit_app, 'Control-Key-plus' : self.sizes_shortcuts,
                        'Control-Key-minus' : self.sizes_shortcuts(-1), 'F5' : self.dt}
        auto_dict, autol_dict = {'KeyPress' : self.emoji_detection, 'KeyRelease' : self.update_insert_image_list}, {'KeyRelease': self.aul_var}
        typef_dict = {'Control-Key-b' : lambda e: self.typefaces(tf='bold'), 'Control-Key-i' : lambda e: self.typefaces(tf='italics'),
                      'Control-Key-u' : lambda e: self.typefaces(tf='underline')}
        editf_dict = {'Control-Key-f' : self.find_text, 'Control-Key-h' : self.replace, 'Control-Key-g' : self.goto}
        filea_dict = {'Control-Key-p' : self.print_file, 'Control-Key-n' : self.new_file, 'Alt-Key-d' : self.copy_file_path,
        'Control-o' : self.open_file, 'Control-Key-s' : self.save}
        textt_dict = {'Control-Shift-Key-j' : self.join_words, 'Control-Shift-Key-u' : self.lower_upper, 'Control-Shift-Key-r' : self.reverse_characters,
                      'Control-Shift-Key-c' : self.reverse_words}
        win_dict = {'F11' : self.full_screen, 'Control-Key-t' : self.topmost}

        # master dict
        bind_dict = {'initial' : initial_dict, 'autof' : auto_dict, 'typef' : typef_dict, 'editf' : editf_dict,
                     'filea' : filea_dict, 'textt' : textt_dict, 'windf' : win_dict, 'autol' : autol_dict}

        # specific mode or all
        if not(mode == 'initial' or mode == 'reset'):
            chosen_dict = bind_dict[mode]
        else:
            chosen_dict = {}
            for subdict in bind_dict.values():
                for key, value in subdict.items():
                    chosen_dict[key] = value

        for index, bond in enumerate(chosen_dict.items()):
            command, function = f'<{bond[0]}>', bond[1]
            bind_to = self
            if mode == 'auto':
                bind_to = self.EgonTE # bind to specific widget
            elif command == '<ComboboxSelected>':
                bind_to = self.font_size # bind to specific widget
                if index > 0:
                    bind_to = self.font_ui # bind to specific widget

            default_bind = True
            if command[-3] == '-' and command[-2].upper() in characters_str:
                bind_to.bind(f'{command[:-1]}{command[-1].upper()}', function) # condition for both last's char being in lower and upper case
            else:
                if not(command[-1].isdigit()): # condition for double chevrons 
                    bind_to.bind(f'<{command}>', function)
                    default_bind = False

            if default_bind: # mainly to complete the last's char being in lower and upper case
                bind_to.bind(command, function)

as you can see, also there’s also modes to configure what to turn on (via another function there’s unbinding and in here we bind again based on the chosen “mode”) – but we don’t need to take a look about that here – it won’t change anything.

my problem is that although the code works fine and without errors and run smoothly when I test the shortcuts (binding) they do not work.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật