|
From: Werner F. B. <wer...@fr...> - 2013-04-20 06:56:58
|
Hi,
I am trying to get matplotlib 1.2.0 to work with wxPython Phoenix - will
provide a patch when it is working.
Made the changes to backend_wx* for things like EmptyImage/EmptyBitmap
and Toolbar but I am stuck on the following.
if bbox is None:
# agg => rgba buffer -> bitmap
if 'phoenix' in wx.PlatformInfo:
return wx.Bitmap.FromBufferRGBA(int(agg.width),
int(agg.height),
memoryview(agg.buffer_rgba()))
else:
return wx.BitmapFromBufferRGBA(int(agg.width), int(agg.height),
agg.buffer_rgba())
else:
# agg => rgba buffer -> bitmap => clipped bitmap
return _WX28_clipped_agg_as_bitmap(agg, bbox)
TypeError: cannot make memory view because object does not have the
buffer interface
File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 63, in
<module>
demo()
File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 60, in demo
app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.6-msw-phoenix\wx\core.py",
line 1841, in MainLoop
rv = wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1209, in _onPaint
self.draw(drawDC=drawDC)
File
"c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 61, in draw
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
File
"c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 173, in _convert_agg_to_wx_bitmap
memoryview(agg.buffer_rgba()))
I tried using "memoryview" based on a suggestion by Robin Dunn, and
based on the following info I see in the debugger that should work no?
agg.buffer_rgba()
<read-write buffer ptr 0x05400638, size 229200 at 0x055FC680>
type(agg.buffer_rgba())
<type 'buffer'>
agg
<matplotlib.backends.backend_agg.RendererAgg instance at 0x04BA0670>
If I don't use "memoryview" (which would probably be preferred) I get
the following exception.
Can someone help us figure this one out.
Thanks
Werner
TypeError: Bitmap.FromBufferRGBA(): argument 3 has unexpected type 'buffer'
File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 63, in
<module>
demo()
File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 60, in demo
app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.6-msw-phoenix\wx\core.py",
line 1841, in MainLoop
rv = wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1209, in _onPaint
self.draw(drawDC=drawDC)
File
"c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 61, in draw
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
File
"c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 173, in _convert_agg_to_wx_bitmap
agg.buffer_rgba())
|
|
From: Werner F. B. <wer...@fr...> - 2013-04-26 06:55:39
|
Hi, Anyone can provide some info on what "agg.buffer_rgba" returns and maybe even some suggestion on how to resolve this issue in the wxagg backend. Thanks Werner P.S. The archive on Sourceforge for this list stops in June 2012, noticed this as I wanted to check if there are answers I didn't get for some reason. http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users On 20/04/2013 08:58, Werner F. Bruhin wrote: > Hi, > > I am trying to get matplotlib 1.2.0 to work with wxPython Phoenix - will > provide a patch when it is working. > > Made the changes to backend_wx* for things like EmptyImage/EmptyBitmap > and Toolbar but I am stuck on the following. > > if bbox is None: > # agg => rgba buffer -> bitmap > if 'phoenix' in wx.PlatformInfo: > return wx.Bitmap.FromBufferRGBA(int(agg.width), > int(agg.height), > memoryview(agg.buffer_rgba())) > else: > return wx.BitmapFromBufferRGBA(int(agg.width), int(agg.height), > agg.buffer_rgba()) > else: > # agg => rgba buffer -> bitmap => clipped bitmap > return _WX28_clipped_agg_as_bitmap(agg, bbox) > > TypeError: cannot make memory view because object does not have the > buffer interface > File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 63, in > <module> > demo() > File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 60, in demo > app.MainLoop() > File "c:\Python27\Lib\site-packages\wx-2.9.6-msw-phoenix\wx\core.py", > line 1841, in MainLoop > rv = wx.PyApp.MainLoop(self) > File "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.py", > line 1209, in _onPaint > self.draw(drawDC=drawDC) > File > "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", > line 61, in draw > self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) > File > "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", > line 173, in _convert_agg_to_wx_bitmap > memoryview(agg.buffer_rgba())) > > I tried using "memoryview" based on a suggestion by Robin Dunn, and > based on the following info I see in the debugger that should work no? > > agg.buffer_rgba() > <read-write buffer ptr 0x05400638, size 229200 at 0x055FC680> > type(agg.buffer_rgba()) > <type 'buffer'> > agg > <matplotlib.backends.backend_agg.RendererAgg instance at 0x04BA0670> > > If I don't use "memoryview" (which would probably be preferred) I get > the following exception. > > Can someone help us figure this one out. > > Thanks > Werner > > > TypeError: Bitmap.FromBufferRGBA(): argument 3 has unexpected type 'buffer' > File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 63, in > <module> > demo() > File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 60, in demo > app.MainLoop() > File "c:\Python27\Lib\site-packages\wx-2.9.6-msw-phoenix\wx\core.py", > line 1841, in MainLoop > rv = wx.PyApp.MainLoop(self) > File "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.py", > line 1209, in _onPaint > self.draw(drawDC=drawDC) > File > "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", > line 61, in draw > self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) > File > "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", > line 173, in _convert_agg_to_wx_bitmap > agg.buffer_rgba()) > > ------------------------------------------------------------------------------ > Precog is a next-generation analytics platform capable of advanced > analytics on semi-structured data. The platform includes APIs for building > apps and a phenomenal toolset for data science. Developers can use > our toolset for easy data analysis & visualization. Get a free account! > http://www2.precog.com/precogplatform/slashdotnewsletter > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
|
From: Michael D. <md...@st...> - 2013-04-26 12:45:07
|
On 04/26/2013 02:57 AM, Werner F. Bruhin wrote: > Hi, > > Anyone can provide some info on what "agg.buffer_rgba" returns and maybe > even some suggestion on how to resolve this issue in the wxagg backend. It returns a Python buffer object on Python 2, though on Python 3 it is a memoryview, since buffer was deprecated. Perhaps wx is also doing something different depending on the version of Python. > > Thanks > Werner > > P.S. > The archive on Sourceforge for this list stops in June 2012, noticed > this as I wanted to check if there are answers I didn't get for some reason. > http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users Yeah -- I've reported that to sourceforge many times. Not sure what the issue is. Personally, I use gmane when I need to search the archive and it works rather well. Mike > > On 20/04/2013 08:58, Werner F. Bruhin wrote: >> Hi, >> >> I am trying to get matplotlib 1.2.0 to work with wxPython Phoenix - will >> provide a patch when it is working. >> >> Made the changes to backend_wx* for things like EmptyImage/EmptyBitmap >> and Toolbar but I am stuck on the following. >> >> if bbox is None: >> # agg => rgba buffer -> bitmap >> if 'phoenix' in wx.PlatformInfo: >> return wx.Bitmap.FromBufferRGBA(int(agg.width), >> int(agg.height), >> memoryview(agg.buffer_rgba())) >> else: >> return wx.BitmapFromBufferRGBA(int(agg.width), int(agg.height), >> agg.buffer_rgba()) >> else: >> # agg => rgba buffer -> bitmap => clipped bitmap >> return _WX28_clipped_agg_as_bitmap(agg, bbox) >> >> TypeError: cannot make memory view because object does not have the >> buffer interface >> File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 63, in >> <module> >> demo() >> File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 60, in demo >> app.MainLoop() >> File "c:\Python27\Lib\site-packages\wx-2.9.6-msw-phoenix\wx\core.py", >> line 1841, in MainLoop >> rv = wx.PyApp.MainLoop(self) >> File "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.py", >> line 1209, in _onPaint >> self.draw(drawDC=drawDC) >> File >> "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", >> line 61, in draw >> self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) >> File >> "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", >> line 173, in _convert_agg_to_wx_bitmap >> memoryview(agg.buffer_rgba())) >> >> I tried using "memoryview" based on a suggestion by Robin Dunn, and >> based on the following info I see in the debugger that should work no? >> >> agg.buffer_rgba() >> <read-write buffer ptr 0x05400638, size 229200 at 0x055FC680> >> type(agg.buffer_rgba()) >> <type 'buffer'> >> agg >> <matplotlib.backends.backend_agg.RendererAgg instance at 0x04BA0670> >> >> If I don't use "memoryview" (which would probably be preferred) I get >> the following exception. >> >> Can someone help us figure this one out. >> >> Thanks >> Werner >> >> >> TypeError: Bitmap.FromBufferRGBA(): argument 3 has unexpected type 'buffer' >> File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 63, in >> <module> >> demo() >> File "h:\devProjectsT\aaTests\matplotlib\wxembedding-5.py", line 60, in demo >> app.MainLoop() >> File "c:\Python27\Lib\site-packages\wx-2.9.6-msw-phoenix\wx\core.py", >> line 1841, in MainLoop >> rv = wx.PyApp.MainLoop(self) >> File "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wx.py", >> line 1209, in _onPaint >> self.draw(drawDC=drawDC) >> File >> "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", >> line 61, in draw >> self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) >> File >> "c:\Python27\Lib\site-packages\matplotlib\backends\backend_wxagg.py", >> line 173, in _convert_agg_to_wx_bitmap >> agg.buffer_rgba()) >> >> ------------------------------------------------------------------------------ >> Precog is a next-generation analytics platform capable of advanced >> analytics on semi-structured data. The platform includes APIs for building >> apps and a phenomenal toolset for data science. Developers can use >> our toolset for easy data analysis & visualization. Get a free account! >> http://www2.precog.com/precogplatform/slashdotnewsletter >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Werner F. B. <wer...@fr...> - 2013-04-27 22:21:33
Attachments:
phoenixComp.patch
|
Hi Michael, On 26/04/2013 14:40, Michael Droettboom wrote: > On 04/26/2013 02:57 AM, Werner F. Bruhin wrote: >> Hi, >> >> Anyone can provide some info on what "agg.buffer_rgba" returns and maybe >> even some suggestion on how to resolve this issue in the wxagg backend. > It returns a Python buffer object on Python 2, though on Python 3 it is > a memoryview, since buffer was deprecated. Perhaps wx is also doing > something different depending on the version of Python. As of Phoenix 2.9.5.81-r73873 matplot works with Phoenix, here is Robin Dunn's comment to the change he did on Phoenix with regards to the buffer handling. Quote The new buffer APIs go as far back as 2.6, IIRC, and the memoryview and bytearray object types are available in 2.7 in addition to 3.x and that I what I'm using in Phoenix. I would have expected MPL to do so also since numpy is an integral part of MPL and the new buffer interface was basically designed for and by numpy... Anyway, while double checking all this I realized that it would not be hard for me to accept old or new buffer objects for source buffers (I'll still use memoryviews or bytearrays when on the producer side of things) so try again after the next snapshot build. My unittests with array.arrrays started working after the change so I expect that MPL's rgba buffer should work too. EndQuote Enclosed is the patch for backend_wx.py and for embedding_in_wx5.py which I used for testing, in the later I use wxversion.select to force selection of a particular version - I think the distribution should still just use ensureMinimal. FYI, documentation for wxPython Phoenix are here: http://wxpython.org/Phoenix/docs/html/index.html And snapshots can be found here: http://wxpython.org/Phoenix/snapshot-builds/ I tested only on Python 2.7.2 on Windows 7. Werner |
|
From: Michael D. <md...@st...> - 2013-05-03 13:13:23
|
Would you mind submitting this as a pull request? Mike On 04/27/2013 06:23 PM, Werner F. Bruhin wrote: > Hi Michael, > > On 26/04/2013 14:40, Michael Droettboom wrote: >> On 04/26/2013 02:57 AM, Werner F. Bruhin wrote: >>> Hi, >>> >>> Anyone can provide some info on what "agg.buffer_rgba" returns and >>> maybe >>> even some suggestion on how to resolve this issue in the wxagg backend. >> It returns a Python buffer object on Python 2, though on Python 3 it is >> a memoryview, since buffer was deprecated. Perhaps wx is also doing >> something different depending on the version of Python. > As of Phoenix 2.9.5.81-r73873 matplot works with Phoenix, here is > Robin Dunn's comment to the change he did on Phoenix with regards to > the buffer handling. > > Quote > > The new buffer APIs go as far back as 2.6, IIRC, and the memoryview > and bytearray object types are available in 2.7 in addition to 3.x and > that I what I'm using in Phoenix. I would have expected MPL to do so > also since numpy is an integral part of MPL and the new buffer > interface was basically designed for and by numpy... > > Anyway, while double checking all this I realized that it would not be > hard for me to accept old or new buffer objects for source buffers > (I'll still use memoryviews or bytearrays when on the producer side of > things) so try again after the next snapshot build. My unittests with > array.arrrays started working after the change so I expect that MPL's > rgba buffer should work too. > > EndQuote > > Enclosed is the patch for backend_wx.py and for embedding_in_wx5.py > which I used for testing, in the later I use wxversion.select to force > selection of a particular version - I think the distribution should > still just use ensureMinimal. > > FYI, documentation for wxPython Phoenix are here: > http://wxpython.org/Phoenix/docs/html/index.html > > And snapshots can be found here: > http://wxpython.org/Phoenix/snapshot-builds/ > > I tested only on Python 2.7.2 on Windows 7. > > Werner > > > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Michael D. <md...@st...> - 2013-05-03 13:14:19
|
FWIW: Matplotlib uses the older buffer interface because that is what the older version of wx used (as well as other GUI toolkits). It would be nice to move to the new memoryview objects, but all of the GUI frameworks will need to move in tandem... Mike On 04/27/2013 06:23 PM, Werner F. Bruhin wrote: > Hi Michael, > > On 26/04/2013 14:40, Michael Droettboom wrote: >> On 04/26/2013 02:57 AM, Werner F. Bruhin wrote: >>> Hi, >>> >>> Anyone can provide some info on what "agg.buffer_rgba" returns and >>> maybe >>> even some suggestion on how to resolve this issue in the wxagg backend. >> It returns a Python buffer object on Python 2, though on Python 3 it is >> a memoryview, since buffer was deprecated. Perhaps wx is also doing >> something different depending on the version of Python. > As of Phoenix 2.9.5.81-r73873 matplot works with Phoenix, here is > Robin Dunn's comment to the change he did on Phoenix with regards to > the buffer handling. > > Quote > > The new buffer APIs go as far back as 2.6, IIRC, and the memoryview > and bytearray object types are available in 2.7 in addition to 3.x and > that I what I'm using in Phoenix. I would have expected MPL to do so > also since numpy is an integral part of MPL and the new buffer > interface was basically designed for and by numpy... > > Anyway, while double checking all this I realized that it would not be > hard for me to accept old or new buffer objects for source buffers > (I'll still use memoryviews or bytearrays when on the producer side of > things) so try again after the next snapshot build. My unittests with > array.arrrays started working after the change so I expect that MPL's > rgba buffer should work too. > > EndQuote > > Enclosed is the patch for backend_wx.py and for embedding_in_wx5.py > which I used for testing, in the later I use wxversion.select to force > selection of a particular version - I think the distribution should > still just use ensureMinimal. > > FYI, documentation for wxPython Phoenix are here: > http://wxpython.org/Phoenix/docs/html/index.html > > And snapshots can be found here: > http://wxpython.org/Phoenix/snapshot-builds/ > > I tested only on Python 2.7.2 on Windows 7. > > Werner > > > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Werner F. B. <wer...@fr...> - 2013-05-03 13:56:39
|
Mike, On 03/05/2013 15:14, Michael Droettboom wrote: > FWIW: Matplotlib uses the older buffer interface because that is what > the older version of wx used (as well as other GUI toolkits). It > would be nice to move to the new memoryview objects, but all of the > GUI frameworks will need to move in tandem... agg.bufferNEW_rgba or something along those lines and then GUI frameworks could move when they want/can, or would that create to big of an overhead on MPL side. Werner |