Hi, this is my first time posting here. I've been working with pygtk and pycairo on a project for about a month now (just learning both of them). Everything has been going fine until a week ago.<br><br>I have a window with some buttons and a large DrawingArea (approximately 950x768 for the drawing area). I'm using the DrawingArea for all of my drawing. Basically, inside the DrawingArea, I draw a circle. Around the circle are rectangles drawn every 10 degrees. Then, I rotate all of that around the center of the DrawingArea.
<br><br>When I added the rotation is when I first hit this problem. I was rendering everything on each refresh, so the application was sucking up a lot of CPU time. I changed it to draw everything to a ImageSurface the one time and then paint that to the screen when the expose-event was signaled. Whenever the expose-event signal is received, all it does is create a cairo context (using
gtk.gdk.Window.cairo_create()), translate to the center, rotate 1 degree and paints the ImageSurface. However, after doing all that, it still sucks up a lot of CPU time from redrawing the DrawingArea all the time. expose-event is getting signaled a lot (about 30 times a second) and each time it has to redraw the entire DrawingArea. Looking through all the examples I can find, the only thing helpful that I've found in this regard is only redrawing the parts that have changed. But, for what I'm trying to do, I have to redraw almost the entire area. Is this slowdown from pycairo? Should I expect this problem if this project were written in C/C++?
<br><br>Another problem I've been having is from rotating the ImageSurface. Whenever I rotate it, the image created is moved outside of the clipping region. Every 90 degrees, it moves back to the correct position. I haven't been able to find anything about this problem. I have three images showing this problem:
<br><br><a href="http://64.150.166.77/python/main-0degrees.png">http://64.150.166.77/python/main-0degrees.png</a><br><a href="http://64.150.166.77/python/main-45degrees.png">http://64.150.166.77/python/main-45degrees.png</a>
<br><a href="http://64.150.166.77/python/main-90degrees.png">http://64.150.166.77/python/main-90degrees.png</a><br><br>In that demo, the image is painted using cairo.Context.set_source_surface(). The origin is translated to the center of the window, rotated, translated back to the top-left, and paints the ImageSource at 0,0. The full source for this demo I wrote is at
<a href="http://64.150.166.77/python/pngtest">http://64.150.166.77/python/pngtest</a>.<br><br>I also put a demo up at <a href="http://64.150.166.77/python/carousel_control">http://64.150.166.77/python/carousel_control</a>
that shows the CPU problem I'm having (the image problem as well).<br><br>If anybody can show me what I'm doing wrong or point me in the right direction, I'd appreciate it. <br> <br>Thanks,<br>Glenn Murphy<br>
<br>