Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interactive mode not working with backends gtk3agg, gtk3cairo #3881

Closed
thraen opened this issue Dec 4, 2014 · 25 comments
Closed

interactive mode not working with backends gtk3agg, gtk3cairo #3881

thraen opened this issue Dec 4, 2014 · 25 comments

Comments

@thraen
Copy link

thraen commented Dec 4, 2014

import matplotlib
matplotlib.use('GTK3Cairo') 
from pylab import *
ion()
plot([1,2,3])
xlabel('hi mom')
show()

doesn't show anything, no error no plot. same for backends gtk3agg.
Only when I close the python shell I get an error:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib64/python3.3/site-packages/matplotlib/_pylab_helpers.py", line 86, in destroy_all
    manager.destroy()
  File "/usr/lib64/python3.3/site-packages/matplotlib/backends/backend_gtk3.py", line 427, in destroy
    self.canvas.destroy()
AttributeError: 'FigureManagerGTK3Agg' object has no attribute 'canvas'
@tacaswell tacaswell added this to the unassigned milestone Dec 4, 2014
@tacaswell
Copy link
Member

What system, which version of mpl, and how did you install it?

@thraen
Copy link
Author

thraen commented Dec 4, 2014

Sorry, this happens on gentoo, python3.3 and 2.7, matplotlib-1.3.0, both installed via gentoo package manager.

@thraen
Copy link
Author

thraen commented Dec 4, 2014

Somebody has the same problem in ubuntu https://bugs.launchpad.net/ubuntu/+source/matplotlib/+bug/1398987

@jenshnielsen
Copy link
Member

I don't think that the GTK3Agg backend works with Python3 in 1.3.x
The GTK3Cairo backend should work thou.

This is due to features not implemented in PyCairo which does not seem to get regular releases anymore. From 1.4 onwards Matplotlib can use CairoCFFI as an alternative to PyCairo and that should work.

@WeatherGod
Copy link
Member

The bug in Ubuntu is for GTK3Cairo. The bug here is for GTK3Agg. Both are
for py3k, though. I suspect something is not py3k compliant in the
backend_gtk3.py, an exception is being thrown, killing the program. Then,
while in the process of destroying everything, a new exception forms
because our cleanup code is not being careful enough.

Does everything work fine without the ion() call?

On Thu, Dec 4, 2014 at 9:51 AM, Jens Hedegaard Nielsen <
notifications@github.com> wrote:

I don't think that the GTK3Agg backend works with Python3 in 1.3.x
The GTK3Cairo backend should work thou.

This is due to features not implemented in PyCairo which does not seem to
get regular releases anymore. From 1.4 onwards Matplotlib can use CairoCFFI
as an alternative to PyCairo and that should work.


Reply to this email directly or view it on GitHub
#3881 (comment)
.

@jenshnielsen
Copy link
Member

This is the Cairo issue mentioned above #1227

@jenshnielsen
Copy link
Member

That being said I can't make interactive work with gtk3Agg using the current master of mpl and CairoCFFI in neither python2 nor 3

@WeatherGod
Copy link
Member

So, it is some sort of interaction between gtk3 backend and ion()?

On Thu, Dec 4, 2014 at 10:05 AM, Jens Hedegaard Nielsen <
notifications@github.com> wrote:

That being said I can't make interactive work with gtk3Agg using the
current master of mpl and CairoCFFI in neither python2 nor 3


Reply to this email directly or view it on GitHub
#3881 (comment)
.

@thraen
Copy link
Author

thraen commented Dec 4, 2014

some more info:

python2.7 + gtk3Cairo + ioff(): works
python2.7 + gtk3Agg + ioff(): works
python2.7 + gtk3Cairo + ion(): no window visible, on cleanup above complaint about missing canvas
python2.7 + gtk3Agg + ion(): no window visible, on cleanup above complaint about missing canvas

python3 + gtk3Cairo + ioff(): works
python3 + gtk3Agg + ioff(): Warning gtk3agg doesn't work with python3, shows empty window
python3 + gtk3Cairo + ion(): no window visible, on cleanup above complaint about missing canvas
python3 + gtk3Agg + ion(): Warning gtk3agg doesn't work with python3, no window showing up

on my machine that is

@thraen
Copy link
Author

thraen commented Dec 4, 2014

I'm not sure if this is related or another problem:
My wx and wxagg backends also don't work in interactive mode, while they work noninteractively. But with those, there's no error message when I close python. Instead I see the plot window flicker up for a few milliseconds.
But this could very well be something completely different. Should I open another issue for that?

@tacaswell tacaswell changed the title matplotlib1.3: interactive mode not working with backends gtk3agg, gtk3cairo interactive mode not working with backends gtk3agg, gtk3cairo Dec 4, 2014
@tacaswell tacaswell modified the milestones: v1.5.x, unassigned Dec 4, 2014
@tacaswell
Copy link
Member

Do the the backends work from an ipython terminal?

@thraen
Copy link
Author

thraen commented Dec 4, 2014

A friend of mine confirmed the same on Ubuntu with iPython (for python 2.7.8) and gtk3cairo backend

@jenshnielsen
Copy link
Member

I did some limited testing. It seems like draw_if_interactive() doesn't work as expected in IPython.

In IPython ( python3 %matplotlib gtk3 i.e. GTK3Agg) the figure is created when plot() is called but not updated when a label is added. Calling plt.draw_if_interactive() has no effect but either calling plt.draw() or clicking on the figure updates it.

Apart from that my tests with master confirm @thraen observes except that I cant reproduce the missing canvas error. I guess that one is due to limitations in Py3Cairo

@tacaswell
Copy link
Member

@thraen Any update on this? Does it behave better with 1.4.3 / the 1.5.0rcs?

@mdehoon
Copy link
Contributor

mdehoon commented Oct 30, 2015

With the current master, it is still broken. I am getting

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-0_unknown-py2.7-macosx-10.9-intel.egg/matplotlib/pyplot.py", line 527, in figure
    **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-0_unknown-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_gtk3cairo.py", line 61, in new_figure_manager
    return new_figure_manager_given_figure(num, thisFig)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-0_unknown-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_gtk3cairo.py", line 69, in new_figure_manager_given_figure
    manager = FigureManagerGTK3Cairo(canvas, num)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-0_unknown-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_gtk3.py", line 451, in __init__
    self.canvas.draw_idle()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-0_unknown-py2.7-macosx-10.9-intel.egg/matplotlib/backends/backend_gtk3.py", line 347, in draw_idle
    self._idle_draw_id = GLib.idle_add(idle_draw)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gi/types.py", line 44, in function
    return info.invoke(*args)
TypeError: Error invoking GLib.idle_add: Unexpected value for argument 'function'

@mdboom
Copy link
Member

mdboom commented Oct 30, 2015

Has ion() ever worked with Gtk3? For me at least, this works fine without it (Fedora 22 and Mac Yosemite). It also works fine inside of IPython (which is the recommended mode for interactive use).

@mdboom
Copy link
Member

mdboom commented Oct 30, 2015

Given this and the recent wx issue, I wonder if we should start displaying warnings if ion is turned on outside of IPython for certain backends.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@anntzer
Copy link
Contributor

anntzer commented Dec 20, 2020

This is still broken now, no window being raised at all. No error is displayed, so I guess the root issue may have changed in between... See also #17769 (comment) for a similar issue on wx.

@Freed-Wu
Copy link

I can reproduce this bug in arch linux.

from matplotlib import pyplot as plt
import numpy as np
import matplotlib as mpl
t = np.arange(0., 5., 0.2)
mpl.use('gtk3agg')  # qt5agg will work
plt.ion()
plt.plot(t, t, t, t**2, t, t**3)

No any interactive window. No any error.

Environment

❯ uname -r
5.14.14-arch1-1
❯ has python ptpython
✓ python 3.9.7
✓ ptpython 3.0.19
❯ python -c 'print(__import__("matplotlib").__version__)'
3.4.3
❯ pacman -Si gtk3|rg Version
Version         : 1:3.24.30+90+g20be04f7ac-1

@tacaswell
Copy link
Member

@Freed-Wu How are you running that code?

@QuLogic
Copy link
Member

QuLogic commented Oct 29, 2021

I don't think PyGObject sets up an input hook, and we don't for GTK, so I expect it does no event loop processing.

@Freed-Wu
Copy link

I run the code in python's REPL.

@mdehoon
Copy link
Contributor

mdehoon commented Oct 30, 2021

@QuLogic The old PyGTK set the input hook via gtk.set_interactive but it looks like this functionality was lost in the transition to PyGObject.

@github-actions
Copy link

github-actions bot commented Mar 8, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Mar 8, 2023
@jklymak
Copy link
Member

jklymak commented Mar 8, 2023

I'll close as very stale. Any issues with modern gut toolkits should get a new reproducible example..

@jklymak jklymak closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2023
@QuLogic QuLogic removed the status: inactive Marked by the “Stale” Github Action label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants