{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4143","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4143/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4143/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4143/events","html_url":"https://github.com/matplotlib/matplotlib/pull/4143","id":58483332,"number":4143,"title":"Refactoring Gcf out of backend code (W-I-P)","user":{"login":"OceanWolf","id":3758703,"avatar_url":"https://avatars.githubusercontent.com/u/3758703?v=3","gravatar_id":"","url":"https://api.github.com/users/OceanWolf","html_url":"https://github.com/OceanWolf","followers_url":"https://api.github.com/users/OceanWolf/followers","following_url":"https://api.github.com/users/OceanWolf/following{/other_user}","gists_url":"https://api.github.com/users/OceanWolf/gists{/gist_id}","starred_url":"https://api.github.com/users/OceanWolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OceanWolf/subscriptions","organizations_url":"https://api.github.com/users/OceanWolf/orgs","repos_url":"https://api.github.com/users/OceanWolf/repos","events_url":"https://api.github.com/users/OceanWolf/events{/privacy}","received_events_url":"https://api.github.com/users/OceanWolf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matplotlib/matplotlib/labels/needs_review","name":"needs_review","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-22T00:40:12Z","updated_at":"2015-02-22T01:45:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/4143","html_url":"https://github.com/matplotlib/matplotlib/pull/4143","diff_url":"https://github.com/matplotlib/matplotlib/pull/4143.diff","patch_url":"https://github.com/matplotlib/matplotlib/pull/4143.patch"},"body":"This PR exists as an alternative to https://github.com/matplotlib/matplotlib/pull/2624\r\n\r\nOkay, the plan here to refactor out ``_pylab_helpers``, which the backends use to get ``Gcf`` out of the backend code, because, ahem, it has nothing to do with the backends.\r\n\r\nTo accomplish this, we shall do this in two passes:\r\n1. The first pass we refactor out all generic backend code out of ``matplotlib.backends.*``, replacing these with common methods, i.e. refactor out ``Gcf`` to ``backend_bases.py``.\r\n2. The second pass we then refactor ``Gcf``  out from ``backend_bases.py``.\r\n\r\nTo accomplish this goal, we first recognise that by definition, the ``FigureManagerBase`` exists as a \"Helper class for pyplot mode, wraps everything up into a neat bundle\", and thus should not contain backend specific code.  This should like in the parts it wraps, namely the Canvas, the Toolbar, and the Window.\r\n\r\nTherefore we move all windowing code into a new class ``WindowBase``, and leave FigureManager to carry out its mission, dropping the ``Base`` as it no longer contains backend specific code.  In this PR we just focus on ``GTK3``.\r\n\r\nBecause ``FigureManager`` retains all of its methods, it *should* have no problem with backwards compatibility, and it also allows us to convert one backend at a time to refactor, not affecting other backends.  Atm I have left the old backend code in place, so that we can deprecate it in case anyone manually creates a ``FigureManagerGtk3`` instance."},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/75414532","html_url":"https://github.com/matplotlib/matplotlib/pull/4143#issuecomment-75414532","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4143","id":75414532,"user":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"created_at":"2015-02-22T01:45:43Z","updated_at":"2015-02-22T01:45:43Z","body":"I provisionally think this is a good idea.  This deserves more attention than I can give it right now, sorry :disappointed: \r\n\r\nWould this method also provide a (sane) path to change which interactive backend you are using on the fly?\r\n\r\nI don't think it will, but make sure that this does not interfere with how we do saving (which is (more-or-less) by replacing the canvas on the `Figure` object and re-calling `draw` and then restoring the old canvas)."}}