[pygtk] URLs in treeviews

Samuel Cormier-Iijima sciyoshi at gmail.com
Sat Sep 9 17:54:52 WST 2006


You should probably connect to "enter-notify-event" and
"leave-notify-event" instead...

Samuel

On 9/9/06, Osmo Salomaa <otsaloma at cc.hut.fi> wrote:
> pe, 2006-09-08 kello 15:36 -0400, hvastani at vt.edu kirjoitti:
> > but how do I make the cursor change to the shape of a hand ( like in
> > web browsers ) when I mouse over this text.
>
> You can connect to the text view's motion-notify-event. Then, when the
> mouse pointer moves, you can get the pointer's coordinates, get the
> gtk.TextIter at that location and get the gtk.TextTags at that iter.
> Based on what those tags are, you can change the cursor.
>
> ----------------------------------------
> def _on_text_view_motion_notify_event(self, text_view, event):
>
>     x, y = text_view.get_pointer()
>     x, y = text_view.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y)
>     tags = text_view.get_iter_at_location(x, y).get_tags()
>     window = text_view.get_window(gtk.TEXT_WINDOW_TEXT)
>     for tag in tags:
>         if tag in self._url_tags:
>             window.set_cursor(HAND_CURSOR)
>             return
>     window.set_cursor(NORMAL_CURSOR)
> ----------------------------------------
>
> However, this is painfully slow! Maybe someone knows a better way?
>
> --
> Osmo Salomaa <otsaloma at cc.hut.fi>
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>


More information about the pygtk mailing list