PySimpleGui 显示数据库中的数据
PySimpleGui Displaying data from a database
PySimpleGui 文档没有解释如何实现 table 元素。目前尚不清楚是否可以将 headers 分配给 table 元素以及如何添加行。是否有使用 table 的简单示例来解释基本功能?
元素 Table
有很多文档。
import PySimpleGUI as sg
headings = ['President', 'Date of Birth']
data = [
['Ronald Reagan', 'February 6'],
['Abraham Lincoln', 'February 12'],
['George Washington', 'February 22'],
['Andrew Jackson', 'March 15'],
['Thomas Jefferson', 'April 13'],
['Harry Truman', 'May 8'],
['John F. Kennedy', 'May 29'],
['George H. W. Bush', 'June 12'],
['George W. Bush', 'July 6'],
['John Quincy Adams', 'July 11'],
['Garrett Walker', 'July 18'],
['Bill Clinton', 'August 19'],
['Jimmy Carter', 'October 1'],
['John Adams', 'October 30'],
['Theodore Roosevelt', 'October 27'],
['Frank Underwood', 'November 5'],
['Woodrow Wilson', 'December 28'],
]
layout = [[sg.Table(data, headings=headings, justification='left', key='-TABLE-')],]
window = sg.Window("Title", layout, finalize=True)
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
print(event, values)
window.close()
PySimpleGui 文档没有解释如何实现 table 元素。目前尚不清楚是否可以将 headers 分配给 table 元素以及如何添加行。是否有使用 table 的简单示例来解释基本功能?
元素 Table
有很多文档。
import PySimpleGUI as sg
headings = ['President', 'Date of Birth']
data = [
['Ronald Reagan', 'February 6'],
['Abraham Lincoln', 'February 12'],
['George Washington', 'February 22'],
['Andrew Jackson', 'March 15'],
['Thomas Jefferson', 'April 13'],
['Harry Truman', 'May 8'],
['John F. Kennedy', 'May 29'],
['George H. W. Bush', 'June 12'],
['George W. Bush', 'July 6'],
['John Quincy Adams', 'July 11'],
['Garrett Walker', 'July 18'],
['Bill Clinton', 'August 19'],
['Jimmy Carter', 'October 1'],
['John Adams', 'October 30'],
['Theodore Roosevelt', 'October 27'],
['Frank Underwood', 'November 5'],
['Woodrow Wilson', 'December 28'],
]
layout = [[sg.Table(data, headings=headings, justification='left', key='-TABLE-')],]
window = sg.Window("Title", layout, finalize=True)
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
print(event, values)
window.close()