Skip to content

Partial update the data in Table element #259

@jason990420

Description

@jason990420
import PySimpleGUI as sg

rows, cols = 20000, 10
headings = [f'Column {i:0>2d}' for i in range(cols)]
data = [[f'Data {row:0>5d}/{col:0>2d}' for col in range(cols)] for row in range(rows)]

sg.theme("LightBlue3")
layout = [
    [sg.Table(data, headings=headings, num_rows=20, justification='c', key='-TABLE-')],
    [sg.Push(), sg.Button("Update"), sg.Push()],
]
window = sg.Window('Title', layout, finalize=True)
table = window['-TABLE-']
widget = table.widget

while True:

    event, values = window.read()

    if event == sg.WIN_CLOSED:
        break
    elif event == 'Update':
        start, stop = 5, 15
        for row in range(start, stop):
            widget.item(table.tree_ids[row], values=[f'{row:0>5d}/{col:0>2d} Data' for col in range(cols)])
        window['-TABLE-'].update(select_rows=[row for row in range(start, stop)])

window.close()

image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions