Remove implicit focus_set() call in FigureCanvasTkAgg.init
#30852
+47
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR summary
Following up on Issue #14081 regarding removal of
focus_set()parameter call in the__init__()function ofFigureCanvasTkAgg. Observed a similar focus structure inFigureFrameWxInterestingly, I'm unable to reproduce the issue. Even after running a script I only get the output -> .!button, so I'm unable to gauge the importance of the fix. This could also be due to an upstream fix in Tkinter but that seems unlikely.
I'm also unsure of where (or if) to document the change in behavior other than the release notes. Standard Tk widgets do not grab focus on creation, so this change would align the canvas with standard behavior.
I have also thought a great deal about the deprecation process. Any logical way to warn the user seems too noisy for
FigureCanvasTkAgg. An unsuspecting user would receive a warning about focus changes even if they had no intention of interacting with the focus mechanism. (As the warning would have to be part of the__init__())Updated and Enhanced
test_backend_tk::test_canvas_focusto handle three cases:focus_force()instead offocus_set()as MacOS tests fail with the latter)plt.show()(Focus - Yes)Added @daniilS as Co-Author for initial ideas
PR checklist