PySimpleGUI / PySimpleGUI/PySimpleGUI

[Enhancement] PySimpleGUI-TK Ability to force window focus

Open
#2,117 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
13.8k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

When running multiple windows, serially where one is closed before another open, on Windows,
new windows do not receive focus after the first window. Only the initial window is given focus after creation.

Where is a workaround available. Use this when you create your window:

   window.TKroot.focus_force()         # Force this window to have focus

   window.Element('-FIRST-INPUT-FIELD-KEY').SetFocus()   # Force this Element to have focus

This will focus the window and move the cursor to the indicated Element.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows behavior with serially created PySimpleGUI-TK windows, then read the existing focus entry points named in the issue: window.TKroot.focus_force() and Element('-FIRST-INPUT-FIELD-KEY').SetFocus(). Done means newly created windows receive focus consistently without requiring this workaround, while the indicated element can still receive cursor focus.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.