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

WX Phoenix AttributeError: 'NavigationToolbar2WxAgg' issue #4460

Closed
jenshnielsen opened this issue May 24, 2015 · 7 comments
Closed

WX Phoenix AttributeError: 'NavigationToolbar2WxAgg' issue #4460

jenshnielsen opened this issue May 24, 2015 · 7 comments
Labels
Milestone

Comments

@jenshnielsen
Copy link
Member

Trying to test the new WX Phonix backend under Python3 I get the following error:

Traceback (most recent call last):
  File "testwx.py", line 4, in <module>
    plt.plot(range(100))
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/pyplot.py", line 3095, in plot
    ax = gca()
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/pyplot.py", line 830, in gca
    ax =  gcf().gca(**kwargs)
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/pyplot.py", line 463, in gcf
    return figure()
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/pyplot.py", line 436, in figure
    **kwargs)
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/backends/backend_wxagg.py", line 113, in new_figure_manager
    return new_figure_manager_given_figure(num, fig)
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/backends/backend_wxagg.py", line 120, in new_figure_manager_given_figure
    frame = FigureFrameWxAgg(num, figure)
  File "/usr/local/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-macosx-10.10-x86_64.egg/matplotlib/backends/backend_wx.py", line 1274, in __init__
    tw, th = self.toolbar.GetSizeTuple()
AttributeError: 'NavigationToolbar2WxAgg' object has no attribute 'GetSizeTuple'

From my limited debugging it seems like GetSizeTuple is no more and we should use GetSize and unpack it manually.

Im using wxPython-Phoenix (3.0.3.dev1820+49a8884) on python 3.4.3 (Homebrew OSX 10.10)

@jenshnielsen
Copy link
Member Author

By the way this is doing the simplest plot that I can think of

import matplotlib
matplotlib.use('WXAgg')
import matplotlib.pyplot as plt
plt.plot(range(100))
plt.show()

@WeatherGod
Copy link
Member

attn: @wernerfb

@wernerfb
Copy link
Contributor

mpl.pyplot uses FigureFrameWx which isn't used by the embedding_in_wx* samples.

After the following change the sample code runs for me on Windows, but no plot is shown, will try to work on this some more next week.

A quick hack (as I don't see how to get that into wx_compat) for this is to make the following change around line 1274:
if wxc.is_phoenix:
tw, th = self.toolbar.GetSize()
fw, fh = self.canvas.GetSize()
else:
tw, th = self.toolbar.GetSizeTuple()
fw, fh = self.canvas.GetSizeTuple()

@wernerfb
Copy link
Contributor

With Py2.7 and 3.0.2 classic I see a crash with no traceback when I run it from the command line, when I run it against Phoenix I see this traceback:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "c:\python27\lib\atexit.py", line 24, in _run_exitfuncs
func(_targs, *_kargs)
File "c:\python27\lib\site-packages\matplotlib_pylab_helpers.py", line 89, in destroy_all
manager.destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py", line 1376, in destroy
self.frame.Destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py", line 1334, in Destroy
wx.Frame.Destroy(self, _args, *_kwargs)
RuntimeError: wrapped C/C++ object of type FigureFrameWxAgg has been deleted
Error in sys.exitfunc:
Traceback (most recent call last):
File "c:\python27\lib\atexit.py", line 24, in _run_exitfuncs
func(_targs, *_kargs)
File "c:\python27\lib\site-packages\matplotlib_pylab_helpers.py", line 89, in destroy_all
manager.destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py", line 1376, in destroy
self.frame.Destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py", line 1334, in Destroy
wx.Frame.Destroy(self, _args, *_kwargs)
RuntimeError: wrapped C/C++ object of type FigureFrameWxAgg has been deleted

Don't understand what mpl.pyplot does here, why destroy the frame?

Hope someone who does use mpl.pyplot with wx can jump in and help on this.

@tacaswell tacaswell added this to the next point release milestone May 24, 2015
@WeatherGod
Copy link
Member

Chances are, for some reason there is a different exception being thrown,
causing python to begin the exit process, and then that hits another bug
during the exit process and you don't see the first exception. Perhaps a
try/except around "show()" with some print messages might be illuminating?

On Sun, May 24, 2015 at 12:32 PM, Werner F Bruhin notifications@github.com
wrote:

With Py2.7 and 3.0.2 classic I see a crash with no traceback when I run it
from the command line, when I run it against Phoenix I see this traceback:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "c:\python27\lib\atexit.py", line 24, in _run_exitfuncs
func(_targs, *_kargs)
File "c:\python27\lib\site-packages\matplotlib_pylab_helpers.py", line 89,
in destroy_all
manager.destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1376, in destroy
self.frame.Destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1334, in Destroy
wx.Frame.Destroy(self, _args, *_kwargs)
RuntimeError: wrapped C/C++ object of type FigureFrameWxAgg has been
deleted
Error in sys.exitfunc:
Traceback (most recent call last):
File "c:\python27\lib\atexit.py", line 24, in _run_exitfuncs
func(_targs, *_kargs)
File "c:\python27\lib\site-packages\matplotlib_pylab_helpers.py", line 89,
in destroy_all
manager.destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1376, in destroy
self.frame.Destroy()
File "c:\python27\lib\site-packages\matplotlib\backends\backend_wx.py",
line 1334, in Destroy
wx.Frame.Destroy(self, _args, *_kwargs)
RuntimeError: wrapped C/C++ object of type FigureFrameWxAgg has been
deleted

Don't understand what mpl.pyplot does here, why destroy the frame?

Hope someone who does use mpl.pyplot with wx can jump in and help on this.


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

@wernerfb
Copy link
Contributor

Will give that a try, will also have to figure out how the wx app is created when one uses mpl.pyplot, hopefully I will find time sometimes towards the end of next week.

@jenshnielsen
Copy link
Member Author

closed by #4479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants