Hello everyone, I'm writing an application which displays a series of parallel graphs, all packed in one window. There is a main graph drawn by a gtk.DrawingArea inheriting class. There are several other graphs, each of them, inheriting the main graph class, overriding the data feed and draw methods.
I created a graphic cursor which tracks the mouse movement when it is on any of the graphs. What I want to achieve is a situation where the cursor is updated to the same position in all the graphs (all cursors follow the mouse position, no matter where the mouse is hovering). My idea was to connect with the mouse movement event and emit a signal which will update the cursor movement. Eventually - it works, but only in the graph in which the mouse is in. It does not propagate to the other graphs. Here are the relevant parts of the code: class priceGraph(gtk.DrawingArea): # Define a new signal - 'data_cursor_moved' __gsignals__ = {'data_cursor_moved' :(gobject.SIGNAL_ACTION, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)) } def __init__(self, caller, graphtype = "FULL"): gtk.DrawingArea.__init__(self) self.connect("expose_event", self.expose) self.add_events(gtk.gdk.POINTER_MOTION_MASK| gtk.gdk.POINTER_MOTION_HINT_MASK) self.connect("motion_notify_event", self.detectMove) self.connect("data_cursor_moved", self.handleMove) <<<rest of init stuff and other methods...>>> def detectMove(self, widget, event): self.emit("data_cursor_moved", event) def handleMove(self, widget, event): """ Redraw the cursor in the event location """ context = self.window.cairo_create() widget.queue_draw_area(*self.cursorRect) context.set_source_rgba(1,0.2,0.3,0.5) context.set_dash([2,3,2],2) context.set_line_width(1) context.move_to(event.x, self.mapY(self.Ymin)) context.line_to(event.x, self.mapY(self.Ymax)) context.stroke() self.cursorRect = (int(event.x-2),int(self.mapY(self.Ymax)),4,int(self.mapY(self.Ymin))) return False <<< Rest of class methods... lots of stuff...>>> gobject.type_register(priceGraph) class stochastics(priceGraph): """Class inheriting main graph, overriding loadData and draw methods""" <<<.....class stuff>>> gobject.type_register(stochastics) Same goes for 4 other similar inheriting classes. My initial understanding was, that the signal catching of the "data_cursor_moved" signal should be inherited by all classes, hence the signal will be caught by all of them. This doesn't happen - where am I wrong here? In the pygtk FAQ 3.11 I read: "A single signal emission will only call handlers attached to the object it was emitted on. The propagation of events up the heirachy is acheived by emitting the signal a number of times." So isn't an inheriting class instance considered the same object? I could not properly understand the second sentence about emitting the signal a number of times. Is this what should be done? Can anyone give me an example code for this? How would you suggest I do that? Thanks very much in advance, Ben.
_______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/