Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8610965

Browse files
authored
Merge pull request #18365 from fariza/toolmanager-qt-focus
move canvas focus after toomanager initialization
2 parents c035f66 + 9145b06 commit 8610965

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,6 @@ def __init__(self, canvas, num):
543543
image = str(cbook._get_data_path('images/matplotlib.svg'))
544544
self.window.setWindowIcon(QtGui.QIcon(image))
545545

546-
# Give the keyboard focus to the figure instead of the manager:
547-
# StrongFocus accepts both tab and click to focus and will enable the
548-
# canvas to process event without clicking.
549-
# https://doc.qt.io/qt-5/qt.html#FocusPolicy-enum
550-
self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
551-
self.canvas.setFocus()
552-
553546
self.window._destroying = False
554547

555548
self.toolbar = self._get_toolbar(self.canvas, self.window)
@@ -578,6 +571,13 @@ def __init__(self, canvas, num):
578571
self.window.show()
579572
self.canvas.draw_idle()
580573

574+
# Give the keyboard focus to the figure instead of the manager:
575+
# StrongFocus accepts both tab and click to focus and will enable the
576+
# canvas to process event without clicking.
577+
# https://doc.qt.io/qt-5/qt.html#FocusPolicy-enum
578+
self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
579+
self.canvas.setFocus()
580+
581581
self.window.raise_()
582582

583583
def full_screen_toggle(self):

0 commit comments

Comments
 (0)