Title: Tkagg backend prints backtrace in some circumstances · Issue #20204 · matplotlib/matplotlib · GitHub
Open Graph Title: Tkagg backend prints backtrace in some circumstances · Issue #20204 · matplotlib/matplotlib
X Title: Tkagg backend prints backtrace in some circumstances · Issue #20204 · matplotlib/matplotlib
Description: Bug report When using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally. It only seems to happen if you save a figure to a PDF, and then save to a PNG with the bbox_inches="tight" opti...
Open Graph Description: Bug report When using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally. It only seems to happen if you save a figure to a PDF, and then save to...
X Description: Bug report When using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally. It only seems to happen if you save a figure to a PDF, and then sav...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/20204
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tkagg backend prints backtrace in some circumstances","articleBody":"### Bug report\r\n\r\nWhen using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally.\r\nIt only seems to happen if you save a figure to a PDF, and then save to a PNG with the `bbox_inches=\"tight\"` option.\r\nDoing just PNG with tight bbox, or PDF then PNG without tight bbox doesn't output the backtrace.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport matplotlib\r\nprint(\"Backend = \", matplotlib.get_backend())\r\nimport matplotlib.pyplot as plt\r\nplt.plot((1,2),(3,4))\r\nprint(\"savefig to PDF\")\r\nplt.savefig(\"fig.pdf\")\r\nprint(\"savefig to PNG\")\r\nplt.savefig(\"fig.png\", bbox_inches=\"tight\")\r\nprint(\"Done\")\r\n```\r\n\r\n**Actual outcome**\r\n```\r\nBackend = TkAgg\r\nsavefig to PDF\r\nsavefig to PNG\r\nException in Tkinter callback\r\nTraceback (most recent call last):\r\n File \"/usr/lib/python3.6/tkinter/__init__.py\", line 1705, in __call__\r\n return self.func(*args)\r\n File \"/usr/lib/python3.6/tkinter/__init__.py\", line 749, in callit\r\n func(*args)\r\n File \"/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py\", line 253, in idle_draw\r\n self.draw()\r\n File \"/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py\", line 9, in draw\r\n super(FigureCanvasTkAgg, self).draw()\r\n File \"/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py\", line 407, in draw\r\n self.figure.draw(self.renderer)\r\n File \"/home/kirkmatt/tktest/lib/python3.6/site-packages/matplotlib/backend_bases.py\", line 1544, in _draw\r\n def _draw(renderer): raise Done(renderer)\r\nmatplotlib.backend_bases._get_renderer.\u003clocals\u003e.Done: \u003cmatplotlib.backends.backend_agg.RendererAgg object at 0x7f019bb6b5c0\u003e\r\nDone\r\n```\r\n\r\n**Expected outcome**\r\nThe exception is caught somewhere and no backtrace is printed.\r\n\r\n**Matplotlib version**\r\n * Operating system: Ubuntu 18.04\r\n * Matplotlib version: 3.3.4 \r\n * Matplotlib backend: TkAgg\r\n * Python version: 3.6.9\r\n * Other libraries: Tkinter installed using `apt install python3-tk`, matplotlib installed in a virtualenv with pip\r\n\r\nThis is possibly related to #18186\r\nThere's also a [stackoverflow question](https://stackoverflow.com/questions/62084819/exception-in-tkinter-callback-using-shap), although in that case they just save to a png and get the traceback, while if I am only saving to PNG I don't.\r\n","author":{"url":"https://github.com/MJKirk","@type":"Person","name":"MJKirk"},"datePublished":"2021-05-11T13:23:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/20204/matplotlib/issues/20204"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5fe36d27-e95f-7c38-c819-843a97e2f4b4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DBC4:20D7FA:109BECD:1648D38:6A5444E8 |
| html-safe-nonce | 930ed7f392c3fb27f4a3f61a258c1395f749d278c1b3561659ccb00807072e9f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkM0OjIwRDdGQToxMDlCRUNEOjE2NDhEMzg6NkE1NDQ0RTgiLCJ2aXNpdG9yX2lkIjoiODMwNzE1MDYyMjcxMDU4MDQ1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | dab9d7a9a0e3061dff1915962ba247c24172b19cb440b7c395a00a67f460e104 |
| hovercard-subject-tag | issue:887272098 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/20204/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e5b37c15a7b27c87a855dbba69b2c69f9c37016534111e8d71e2b55f3aa267d9/matplotlib/matplotlib/issues/20204 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e5b37c15a7b27c87a855dbba69b2c69f9c37016534111e8d71e2b55f3aa267d9/matplotlib/matplotlib/issues/20204 |
| og:image:alt | Bug report When using the tkagg backend, a backtrace gets printed, although it doesn't stop and the script finishes normally. It only seems to happen if you save a figure to a PDF, and then save to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MJKirk |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width