pythonuser-interfacepysimplegui

Is it possible to make non-first tab selected in PySimpleGUI window startup?


window = sg.Window("foobar", layout, margins=(2, 2), finalize=True)
window.Element('-ENCR_TAB-').Select()

What I see is that the first tab is selected and only after a little while the '-ENCR_TAB-' (the second tab) is selected as expected. Is it possible to have it selected by default without such a delay?


Solution

  • There's no option about default selected tab, only work the way as you shown.

    If there's any update or delay when window shown, IMO, you can move window out of screen before it ready, then move it back.

    location = sg.Window.get_screen_size()
    window = sg.Window("foobar", layout, margins=(2, 2), location=location, finalize=True)
    window['-ENCR_TAB-'].select()
    window.refresh()
    window.move_to_center()