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

Unable to run ScrollingPlot example #4552

Closed
wakatana opened this issue Jun 23, 2015 · 1 comment
Closed

Unable to run ScrollingPlot example #4552

wakatana opened this issue Jun 23, 2015 · 1 comment

Comments

@wakatana
Copy link

Following example http://wiki.scipy.org/Cookbook/Matplotlib/ScrollingPlot?action=show throws following error:

Traceback (most recent call last):
File "scrollingPlot.py", line 88, in
app = MyApp()
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/core.py", line 8628, in __init_
self.BootstrapApp()
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8196, in _BootstrapApp
return _core.PyApp__BootstrapApp(args, *kwargs)
File "scrollingPlot.py", line 82, in OnInit
self.frame = MyFrame(parent=None,id=-1)
File "scrollingPlot.py", line 21, in init
self.scroll_range)
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/core.py", line 11226, in SetScrollbar
return _core.Window_SetScrollbar(args, *kwargs)
wx._core.PyAssertionError: C++ assertion "sb" failed at ../src/gtk/window.cpp(4754) in SetScrollbar(): this window is not scrollable

PS: I've opened issue first time on scipy scipy/scipy#4988 but I was suggested to open issue on matplotlib because it looks like matplotlib problem

PPS: The discussion is also on SO http://stackoverflow.com/questions/31001713/plotting-the-data-with-scrollable-x-time-horizontal-axis-on-linux

[TAC added markup]

@tacaswell
Copy link
Member

The problem is that the FigureCanvasWxAgg object is not 'scrollable' It looks like it is derived from wx.Panel which is a parent class to the classes in WX that do the scrolling (I am not a wx expert, this is from 10min of googling/skimming the code).

I can reproduce this error but am an unclear on when it ever worked as FigureCanvasWx has derived from wx.Panel since at least 2005 (80cd333 can probably chase that back further) so I suspect that this is a version of wx thing and not something mpl can do something about.

@rgommers Given that this example was last touched at 2010-01-03 15:12:46 and something has rotted underneath it, it should just be removed or refereed to a wx expert.

I am closing this as this can be reproduced with no mpl involved at all and is from documentation we (mpl) does not maintain.

import wx


class MyFrame(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'scrollable plot',
                          style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER,
                          size=(800, 400))
        self.panel = wx.Panel(self, -1)

        self.panel.SetScrollbar(wx.HORIZONTAL, 0, 5,
                                400)

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.panel.SetSizer(sizer)
        self.panel.Fit()


class MyApp(wx.App):
    def OnInit(self):
        self.frame = MyFrame(parent=None, id=-1)
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

if __name__ == '__main__':
    app = MyApp()
    app.MainLoop()

raises

19:53 $ python wx_scroll.py 
19:56:39: Warning: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1008,wx containers,compatible with 2.8),
and wxPython used 3.0 (wchar_t,compiler with C++ ABI 1002,wx containers,compatible with 2.8).
Traceback (most recent call last):
  File "wx_scroll.py", line 28, in <module>
    app = MyApp()
  File "/usr/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 8628, in __init__
    self._BootstrapApp()
  File "/usr/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 8196, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "wx_scroll.py", line 22, in OnInit
    self.frame = MyFrame(parent=None, id=-1)
  File "wx_scroll.py", line 12, in __init__
    400)
  File "/usr/lib/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 11226, in SetScrollbar
    return _core_.Window_SetScrollbar(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "sb" failed at ./src/gtk/window.cpp(4754) in SetScrollbar(): this window is not scrollable

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

2 participants