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

Commitf71ec63

Browse files
authored
Merge pull request#17789 from richardsheridan/tkagg_improvements
MNT: Tk backend improvements
2 parents4e11730 +502dd11 commitf71ec63

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

‎lib/matplotlib/backends/_backend_tk.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def __init__(self, figure, master=None, resize_callback=None):
209209
# to the window and filter.
210210
deffilter_destroy(event):
211211
ifevent.widgetisself._tkcanvas:
212-
self._master.update_idletasks()
213212
self.close_event()
214213
root.bind("<Destroy>",filter_destroy,"+")
215214

@@ -233,7 +232,6 @@ def resize(self, event):
233232
self._tkcanvas.create_image(
234233
int(width/2),int(height/2),image=self._tkphoto)
235234
self.resize_event()
236-
self.draw()
237235

238236
defdraw_idle(self):
239237
# docstring inherited
@@ -383,6 +381,16 @@ def flush_events(self):
383381
# docstring inherited
384382
self._master.update()
385383

384+
defstart_event_loop(self,timeout=0):
385+
# docstring inherited
386+
iftimeout>0:
387+
self._master.after(int(1000*timeout),self.stop_event_loop)
388+
self._master.mainloop()
389+
390+
defstop_event_loop(self):
391+
# docstring inherited
392+
self._master.quit()
393+
386394

387395
classFigureManagerTk(FigureManagerBase):
388396
"""
@@ -527,10 +535,6 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
527535
ifpack_toolbar:
528536
self.pack(side=tk.BOTTOM,fill=tk.X)
529537

530-
defdestroy(self,*args):
531-
delself.message
532-
tk.Frame.destroy(self,*args)
533-
534538
defset_message(self,s):
535539
self.message.set(s)
536540

@@ -554,8 +558,6 @@ def set_cursor(self, cursor):
554558
window.configure(cursor=cursord[cursor])
555559
excepttkinter.TclError:
556560
pass
557-
else:
558-
window.update_idletasks()
559561

560562
def_Button(self,text,image_file,toggle,command):
561563
image= (tk.PhotoImage(master=self,file=image_file)

‎lib/matplotlib/backends/backend_tkagg.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ class FigureCanvasTkAgg(FigureCanvasAgg, FigureCanvasTk):
88
defdraw(self):
99
super().draw()
1010
_backend_tk.blit(self._tkphoto,self.renderer._renderer, (0,1,2,3))
11-
self._master.update_idletasks()
1211

1312
defblit(self,bbox=None):
1413
_backend_tk.blit(
1514
self._tkphoto,self.renderer._renderer, (0,1,2,3),bbox=bbox)
16-
self._master.update_idletasks()
1715

1816

1917
@_BackendTk.export

‎lib/matplotlib/backends/backend_tkcairo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def draw(self):
2323
_backend_tk.blit(
2424
self._tkphoto,buf,
2525
(2,1,0,3)ifsys.byteorder=="little"else (1,2,3,0))
26-
self._master.update_idletasks()
2726

2827

2928
@_BackendTk.export

‎lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,32 @@ def test_webagg():
199199
conn.close()
200200
proc.send_signal(signal.SIGINT)
201201
assertproc.wait(timeout=_test_timeout)==0
202+
203+
204+
@pytest.mark.backend('TkAgg',skip_on_importerror=True)
205+
deftest_never_update(monkeypatch,capsys):
206+
importtkinter
207+
monkeypatch.delattr(tkinter.Misc,'update')
208+
monkeypatch.delattr(tkinter.Misc,'update_idletasks')
209+
210+
importmatplotlib.pyplotasplt
211+
fig=plt.figure()
212+
plt.show(block=False)
213+
214+
# regression test on FigureCanvasTkAgg
215+
plt.draw()
216+
# regression test on NavigationToolbar2Tk
217+
fig.canvas.toolbar.configure_subplots()
218+
219+
# check for update() or update_idletasks() in the event queue
220+
# functionally equivalent to tkinter.Misc.update
221+
# must pause >= 1 ms to process tcl idle events plus
222+
# extra time to avoid flaky tests on slow systems
223+
plt.pause(0.1)
224+
225+
# regression test on FigureCanvasTk filter_destroy callback
226+
plt.close(fig)
227+
228+
# test framework doesn't see tkinter callback exceptions normally
229+
# see tkinter.Misc.report_callback_exception
230+
assert"Exception in Tkinter callback"notincapsys.readouterr().err

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp