[pygtk] How to Tell Window to Redraw
Nikolaus Rath
Nikolaus at rath.org
Sun Apr 6 19:24:20 WST 2008
Hello,
I want to write a small script that shows a number of bodies moving in
a 2d coordinate systems. The positions at different times are stored
in a csv file. Since I have wanted to learn some python for quite some
time I have decided to try this in pygtk.
I have worked through the pygtk tutorial (http://www.pygtk.org/pygtk2tutorial)
and tried to fill in the gaps using the reference manual
(http://www.pygtk.org/docs/pygtk/index.html). Unfortunately the later
turned out to be of practically no use to me since I haven't really
reached the level where I have an idea what functionality I can find
where in the API and class hierarchy. Therefore I'm now asking for
help here.
I have created the window as
class Animate:
def __init__(self):
self.xrange = 800
self.yrange = 800
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("Plot")
window.connect("destroy", lambda w: gtk.main_quit())
self.area = gtk.DrawingArea()
self.area.set_size_request(self.xrange, self.yrange)
self.pangolayout = self.area.create_pango_layout("")
window.add(self.area)
self.area.connect("expose-event", self.area_expose_cb)
self.area.show()
window.show()
gobject.timeout_add(1000, self.on_timeout)
the function area_expose_cb draws the coordinate system and the bodies
while the function on_timeout updates reads the positions of the
bodies and writes them into variables that are used by area_expose_cb.
My question is now: How can I force the window to redraw itself after
I have updated the state variables? I have tried to send an expose
event like this
self.area.emit("expose-event")
but apparently this function requires a second parameter of type
GdkEvent. Unfortunately I was not able to find the "emit" function nor
any description of GdkEvent in the reference manual.
Can anyone tell me where I can find the emit function documented or
the proper way of redrawing a window?
Thanks in advance!
-Nikolaus
--
Nikolaus at rath.org | College Ring 6, 28759 Bremen, Germany
Class of 2008 - Physics | Jacobs University Bremen
»My opinions may have changed, but not the fact that I am right.«
More information about the pygtk
mailing list