【发布时间】:2021-03-18 22:22:39
【问题描述】:
我正在使用 PySimpleGui 开发一个应用程序,它将从列表中分配按钮文本。用户搜索时,按钮上的文本会发生变化。我希望能够在按下按钮时阅读、打印和分配按钮文本。我怎么做?这是代码。我尝试了几件事无济于事。代码末尾的两条 print 语句是余数。
import PySimpleGUI as sg
selection_button_text_data = ['Like a Rolling Stone','Bob Dylan','The Sound of Silence','Simon & Garfunkel','Respect','Aretha Franklin','A Day In The Life','The Beatles']
layout =[
[
[sg.Button(selection_button_text_data[0])],
[sg.Button(selection_button_text_data[1])],
[sg.Button(selection_button_text_data[2])],
[sg.Button(selection_button_text_data[3])]
]
]
window = sg.Window('Window Title', layout)
event, values = window.read()
window.close()
print(values)
print(sg.Button.GetText())
【问题讨论】:
-
您想即时更新按钮?
-
奥尔德文是的,我愿意。
标签: python user-interface pysimplegui