Python 如何从元组列表中为PySimpleGUI列表框中的选定值返回第二项

Python 如何从元组列表中为PySimpleGUI列表框中的选定值返回第二项,python,pysimplegui,Python,Pysimplegui,我想单击一个列表框值(attriblist)并显示相关的韵文(biglist元组中的第二个值)。我无法将一个列表与第二个列表同步。不过,可能更多的是python问题,而不是PySImpleGUI问题 import PySimpleGUI as sg biglist = [('Abundant Life','John 10:10'), ('Angels','Psalm 103:20'), ('Boldness','Proverbs 28:1')] attriblist = [] for i

我想单击一个列表框值(attriblist)并显示相关的韵文(biglist元组中的第二个值)。我无法将一个列表与第二个列表同步。不过,可能更多的是python问题,而不是PySImpleGUI问题

import PySimpleGUI as sg

biglist = [('Abundant Life','John 10:10'),
('Angels','Psalm 103:20'), 
('Boldness','Proverbs 28:1')]

attriblist = []

for idx, (promise, verse) in enumerate(biglist):    
    attriblist.append(str(promise))
  
sg.theme('Tan Blue')

layout = [[sg.Text('Pick an attribute and see verse of promise.')],
          [sg.Listbox(attriblist, size=(20, 20), key='-LIST-', enable_events=True)],
          [sg.Multiline(size = (58, 5), key = '_multiline_', autoscroll = False, disabled=True)],
          [sg.Button('Exit')]]

window = sg.Window("God's Promises", layout)

while True: 

    event, values = window.read()
    if event in (sg.WIN_CLOSED, 'Exit'):
        break
    for index,verse in enumerate(values['-LIST-']):
        #print(verse)
        for idx, (promise, verse) in enumerate(biglist):
            window['_multiline_'].update(verse)
            

window.close()
这个怎么样,

将PySimpleGUI导入为sg
大名单=[
(《丰盛的生命》,《约翰福音10:10》),
(《天使》,《诗篇103:20》),
(《勇敢》,《箴言28:1》)
]
attrib_dict={key:key的值,biglist中的值}
attrib_list=已排序(attrib_dict.keys())
sg.主题(‘棕褐色’)
设置选项(字体=('Courier New',12))
布局=[
[sg.Text('选择一个属性并查看承诺的诗句')],
[sg.Listbox(attrib_list,size=(20,10),key='-list-',enable_events=True),
sg.Multiline(大小=(60,10),键='-Multiline-',autoscroll=False,disabled=True)],
[sg.按钮('退出')]]
window=sg.window(“上帝的应许”,布局,最终确定=True)
窗口['-多行-'].Widget.configure(spacing1=1)
尽管如此:
事件,值=window.read()
如果事件发生(sg.WIN_关闭,“退出”):
打破
elif事件=='-LIST-':
选择=值[事件][0]
窗口['-MULTILINE-'].更新(值=attrib_dict[selection])
window.close()