При втором и далее выборах в Listbox сохраняется и действует первый выбор item. Как сделать чтобы он каждый раз принмал выбранный item в Listbox

есть окно, в котором отображается список с именами файлов, с двойным щелчком по нему, который должен открыться в окне, и список должен исчезнуть на некоторое время. Итак, вот как открыть окно не того файла, который был открыт при запуске, а выбранного файла. Если открыть программу и выбрать файл, то он откроется в нужном окне, но если вы вернетесь в окно с листбоксом и выберете другое имя файла в списке, откроется предыдущий файл. Я пытался реализовать через dict tkinter, но что-то было не так ... ((

there is a window in which a listbox with file names is shown, with a double click on which it should open in the window and the listbox should disappear for a while. So here's how to make the window open not the same file that was opened at startup, but the selected file. If you open the program and select a file, it will open, but if you select a different file name in the listbox, the previous file will open. I tried to implement through dict tkinter but something was wrong...(( What?

theory_themes = {
        0: 'theme0',
                1: 'theme1',
                2: 'theme2'
                }

fileNum_PathOfFile = {
            theory_themes.get(0): "0.txt",
            theory_themes.get(1): "1.txt",
        theory_themes.get(2): "2.txt"
}

listbox_of_theory_themes = Listbox(right_field_frame, 
                                   listvariable=fileNum_PathOfFile.keys(), selectmode=SINGLE)

def part1_open_theme(event):
    listbox_of_1_themes.pack_forget()
    selected_key = listbox_of_1_themes.curselection()
    selected_value = listbox_of_1_themes.get(listbox_of_1_themes.curselection())

    pseudo_FilePath = fileNum_PathOfFile.get(listbox_of_1_themes.get(selected_key))
    open_file_by_path(pseudo_FilePath)


def choose_listbox_theme(event):
    listbox_of_2_themes.pack_forget()
    listbox_of_3_themes.pack_forget()
    for theme in fileNum_PathOfFile.keys():
        listbox_of_1_themes.insert(END, theme)
    TText.pack_forget()
    listbox_of_1_themes.bind('<<ListboxSelect>>', part1_open_theme)
    listbox_of_1_themes.pack(side=LEFT, anchor=NW)

Ответы (0 шт):