Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FigureCanvasTkAgg.__init__ steals focus #14081

Open
@loehnertj

Description

@loehnertj

Bug report

Bug summary

I am using embedded plots in a TKinter application. In theFigureCanvasTkAgg.__init__ method, at the end there is a call to focus_set, stealing focus upon construction of the widget. To make matters worse, focus stealing happens asynchronous.

Code for reproduction

importtkinterastkfrommatplotlib.figureimportFigurefrommatplotlib.backends.backend_tkaggimportFigureCanvasTkAggt=tk.Tk()b1=tk.Button(t,text='My Button')b1.pack(side='top')f=Figure()fc=FigureCanvasTkAgg(f,t)fc.get_tk_widget().pack()# !! after FigureCanvasTkAgg initialization !!b1.focus_set()t.after(500,lambda:print(t.focus_get()))t.mainloop()

Actual outcome

C:\TEMP>python tkagg.py.!canvas

I.e. canvas has focus although button should have it.

Expected outcome

  1. Creating a widget of any kind should never steal focus.
  2. Using focus_set() afterwards should be able to reset focus.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 2.0.2
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.2
  • Jupyter version (if applicable):
  • Other libraries:

Python installed via official installer, matplotlib via pip.

The call tofocus_set is still present in the master version:

self._tkcanvas.focus_set()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp