[matplotlib-devel] Unnecessary rerendering in wx/wxagg backends

2008-03-31 Thread Gregor Thalhammer
Dear developers,

I discovered that in backend_wx.py in _onPaint(), the callback function 
for repainting a matplotlib figure, every time a repaint is done also 
the bitmap is rerendered:

backend_wx.py/_onPaint():
...
# Render to the bitmap
self.draw(repaint=False)
...

This also affects the behaviour of the wxagg backend. Rerendering and 
therefore also repainting gets quite slow if, e.g., images are included 
in the figure. I can see this by simply dragging another window across 
the matplotlibfigure. Commenting out the rerendering I get a much 
smoother behaviour. I could not observe problems except that sometimes 
some parts of the figure are not properly repainted if the matplotlib 
figure is in the background (I only tested the wxagg backend). Therefore 
it seems that this rerendering every time a repaint is performed is not 
really necessary and should be avoided.

I tested this on matplotlib 0.91.2 on WinXP, Python 2.5, wx 2.8.7. I 
checked that in the current svn version the _onPaint() function is 
unchanged.

Gregor

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Unnecessary rerendering in wx/wxagg backends

2008-03-31 Thread Erik Tollerud
I tested this on 0.91.2 on Ubuntu Gutsy, and wx 2.8.7.1, and found
that when I bring up a new window, I see a black canvas and it doesn't
draw any of the matplotlib objects until I do something like resizing
that must explicitly call a draw at some point.  This may be why it's
in there... perhaps some sort of checking to see if any draw has been
performed yet?

On Mon, Mar 31, 2008 at 7:58 AM, Gregor Thalhammer
<[EMAIL PROTECTED]> wrote:
> Dear developers,
>
>  I discovered that in backend_wx.py in _onPaint(), the callback function
>  for repainting a matplotlib figure, every time a repaint is done also
>  the bitmap is rerendered:
>
>  backend_wx.py/_onPaint():
>  ...
>  # Render to the bitmap
>  self.draw(repaint=False)
>  ...
>
>  This also affects the behaviour of the wxagg backend. Rerendering and
>  therefore also repainting gets quite slow if, e.g., images are included
>  in the figure. I can see this by simply dragging another window across
>  the matplotlibfigure. Commenting out the rerendering I get a much
>  smoother behaviour. I could not observe problems except that sometimes
>  some parts of the figure are not properly repainted if the matplotlib
>  figure is in the background (I only tested the wxagg backend). Therefore
>  it seems that this rerendering every time a repaint is performed is not
>  really necessary and should be avoided.
>
>  I tested this on matplotlib 0.91.2 on WinXP, Python 2.5, wx 2.8.7. I
>  checked that in the current svn version the _onPaint() function is
>  unchanged.
>
>  Gregor
>
>  -
>  Check out the new SourceForge.net Marketplace.
>  It's the best place to buy or sell services for
>  just about anything Open Source.
>  http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
>  ___
>  Matplotlib-devel mailing list
>  Matplotlib-devel@lists.sourceforge.net
>  https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>



-- 
Erik Tollerud
Graduate Student
Center For Cosmology
Department of Physics and Astronomy
4155B Frederick Reines Hall
University of California, Irvine
Office Phone: (949)824-2996
Cell: (651)307-9409
[EMAIL PROTECTED]

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Unnecessary rerendering in wx/wxagg backends

2008-03-31 Thread Christopher Barker
Erik Tollerud wrote:
> I tested this on 0.91.2 on Ubuntu Gutsy, and wx 2.8.7.1, and found
> that when I bring up a new window, I see a black canvas and it doesn't
> draw any of the matplotlib objects until I do something like resizing
> that must explicitly call a draw at some point.

yup, same here.

I'm using wxAgg, and FigureCanvas.draw() just doesn't seem to be getting 
called when I call Figure.draw()

It looks like it's designed to work the other way -- the Window needs to 
call self.figure.draw(self.renderer) when it wants the image drawn. 
There is an efficiency to this, as the figure doesn't get rendered until 
the GUI toolkit needs it. However, having it re-render on every Paint 
call isn't right either.

So how should this work? I'd like to be able to call Figure.draw(), and 
have the figure re-draw itself - but then it needs to be able to tell 
the backend Canvas that it needs to be drawn.

It seems that the figure needs to keep a flag that indicated when it is 
"dirty", then the paint handler could check that, and call draw if need 
be. Is there one already?

This all seems a bit awkward though. I've written a bunch of double 
buffered code, and I try to do it like this:

The Paint handler only blits.
There is a draw routine that actually draws the off-screen bitmap. It is 
called:
   - when the bitmap is new, like in a Re-size event
   - when the drawing changes.

In the MPL case, then, it seems that figure.draw() should call that draw 
routine, but maybe it doesn't know anything about its canvas. Ah -- ye 
sit does - figure.canvas.

OK, so a draw_event is getting called, which I guess is where the 
drawing should happen, but I'm getting lost now!

-Chris







-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] TKinter : 'module' object has no attribute 'tkinit'

2008-03-31 Thread fiacre
As it happens, the box I was working on totally borked (hardware 
problem).  I've built a CentOS box and am running fine now --- I made a 
point of installing X, gtk, cairo, tcl, tk and other graphics libs 
before building python and matplotlib on the box.

So, the problems seems to be related to the way python and/or Tkinter 
was built.  X was not on the box when I built python initially.

* shrug *

Things work nicely now.


Michael Droettboom wrote:
> It doesn't look like a faulty X setup, and since you *do* get a 
> window, it's unlikely it's a Tkinter problem.
>
> The fishy thing here is that _tkagg should be a C extension, have a 
> .so file extension and have only the following members -->
>
> >>> dir(_tkagg)
> ['__doc__', '__file__', '__name__', '_pyobj_addr', 'tkinit']
>
> tkagg (without the underscore), on the other hand, is a true Python 
> module, would have a .pyc extension and all of the members you posted.
>
> So, somehow, tkagg got renamed to _tkagg on your system.  I'm not sure 
> how the build script may have done that.  Does removing
>
>  /usr/lib/python2.5/site-packages/matplotlib/backends/_tkagg.pyc
>
> help?  (It's generally safe to remove .pyc files since they are 
> regenerated by the Python compiler).  Do you have a _tkagg.py sitting 
> in that directory?
>
> Did you build matplotlib from the source tarball, a Gentoo port (or 
> whatever they're called), or some other way?
>
> If you built yourself, (even if the above suggestion worked), could 
> you try cleanly rebuilding again by:
>
>  1. deleting the build directory under the source tree
>  2. deleting /usr/lib/python2.5/site-packages/matplotlib
>  3. "python setup.py install"
>
> and let us know if that worked?
>
> Cheers,
> Mike
>
> Darren Dale wrote:
>> Do you have the tk-devel packages installed? When you run setup.py, 
>> there is a report at the beginning which lists all the required and 
>> optional dependencies, would you post that?
>>
>> On Friday 21 March 2008 08:52:40 am fiacre wrote:
>>  
>>> I agree -- I don't believe it built correctly either ...
>>>
>>> Python 2.5.1 (r251:54863, Mar 20 2008, 04:03:41)
>>> [GCC 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>  >>> from matplotlib.backends import _tkagg
>>>  >>> _tkagg.__file__
>>>
>>> '/usr/lib/python2.5/site-packages/matplotlib/backends/_tkagg.pyc'
>>>
>>>  >>> dir(_tkagg)
>>>
>>> ['AxisMenu', 'Figure', 'FigureCanvasAgg', 'FigureCanvasBase',
>>> 'FigureCanvasTkAgg', 'FigureManager', 'FigureManagerBase',
>>> 'FigureManagerTkAgg', 'FileDialog', 'Gcf', 'GraphicsContextBase',
>>> 'NavigationToolbar', 'NavigationToolbar2', 'NavigationToolbar2TkAgg',
>>> 'PIXELS_PER_INCH', 'RendererBase', 'SubplotTool', 'Tk', '__builtins__',
>>> '__doc__', '__file__', '__name__', 'asarray', 'backend_version',
>>> 'cursord', 'cursors', 'division', 'draw_if_interactive', 'enumerate',
>>> 'error_msg_tkpaint', 'is_string_like', 'math', 'matplotlib',
>>> 'new_figure_manager', 'os', 'raise_msg_to_str', 'rcParams', 'round',
>>> 'show', 'sys', 'tkagg', 'verbose', 'windowing']
>>>
>>>
>>>
>>> I don't see anything obviously wrong though -- I am wondering if my X
>>> setup is faulty.
>>>
>>> Thanks!
>>>
>>> Michael Droettboom wrote:
>>>
 It looks like the _tkagg C extension didn't build correctly -- it
 really should have a tkinit method.

 Can you please try the following and send me the output (inside the
 Python interpreter)...

  
>>> from matplotlib.backends import _tkagg
>>> _tkagg.__file__
>>> dir(_tkagg)
>>> 
 Thanks!

 Mike

 fiacre wrote:
  
> I'm running Idle via X forwarding to my Windows desktop (running
> Cygwin).
>
> I've installed tcl/tk and python with Tkinter as a backend.
>
> When I call pylab.show(),  I always get the error :
>  >>> pylab.show()
>
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1403, in __call__
> return self.func(*args)
>   File
> "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", 
>
> line 151, in resize
> self.show()
>   File
> "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py", 
>
> line 155, in draw
> tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
>   File
> "/usr/lib/python2.5/site-packages/matplotlib/backends/tkagg.py", line
> 14, in blit
> _tkagg.tkinit(id(tk), 0)
> AttributeError: 'module' object has no attribute 'tkinit'
>
>
> And an empty matplotlib window opens on my desktop.
>
>
> Should I try gtk as a backend???
>
> TIA
>
> -- Andrew
>
>  
>
> -
>
> This SF.net email is sponso