On an expose, you have to draw everything that is exposed. The
drawingarea has no memory.
The event will contain an indication of the exposure area. My
reference code is very old, gtk 1.x so this has probably changed, but
it used to be event.area contained (x, y, width, height) of the
exposed area.
Then you have to go to your data store, or logic, to know if you have
something to redraw in that given area.
On Oct 12, 2007, at 1:15 PM, Rory Walsh wrote:
I'm trying to animate the drawing of a line using drawingarea but
I'm having some difficulty. I thought that I could just call
draw_point() and increment the X coordinate each time but my old
points are not staying on the screen? My code is below, any ideas?
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import math
def redraw_timeout(object):
object.window.invalidate_rect((0,0,200,200),False)
return True
class drawSomething:
x = 0
def on_expose(self, drawingarea, event):
# get the GdkWindow
self.window = event.window
# get the GC
gc = self.window.new_gc()
# draw a line?
self.drawingarea.window.draw_point(gc, self.x, 100)
self.x = self.x+1
if(self.x>200):
self.x = 0
def __init__(self):
self.win = gtk.Window()
self.win.connect("destroy", gtk.mainquit)
self.win.show()
self.drawingarea = gtk.DrawingArea()
self.drawingarea.connect("expose-event", self.on_expose)
self.drawingarea.show()
self.win.add(self.drawingarea)
def main(self):
self.drawingarea.show()
gtk.main()
# enter the mainloop
if __name__ == "__main__":
draw = drawSomething()
source_id = gobject.timeout_add(1, redraw_timeout, draw)
draw.main()
regards,
Rory.
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
Steve McClure
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/