[pygtk] button-press-event on a TreeViewColumn Header?

saeed saeed.gnu at gmail.com
Thu Jun 18 12:58:00 WST 2009


Tim Evans: But it doesn't work for me! The "button" receives neither
"button-press-event" or "pressed" or "clicked". I receives only an
expose-event when resizing column.

def show_event(widget, event):
  print type(widget), event.type.value_name
button.connect('event', show_event)

On 6/18/09, Tim Evans <t.evans at aranz.com> wrote:
> Alessandro Dentella wrote:
>> Hi,
>>
>>   I'd like to connect to a 'button-press-event' of a column header of a
>>   TreeViewColumn. As only clicked is provided, I set the widget::
>>
>>         label = gtk.Label(title)
>>         box = gtk.EventBox()
>>         box.add(label)
>>         column.set_widget(box)
>>         box.connect('button-press-event', self.box_clicked_cb)
>> #        column.connect('clicked', self.clicked_cb)
>>
>>   but box_clicked_cb is never called. Why that?
>>
>>   Any Hints?
>
> I've used this code as a hack to get the column header button before:
>
>    temp = gtk.Label('Temp')
>    column.set_widget(temp)
>    button = temp.get_parent().get_parent().get_parent()
>    column.set_widget(None)
>    temp.destroy()
>
> Now what you have in 'button' is the gtk.Button widget that is used to
> render the column header.  Your button-press-event connection will work
> on that widget, provided you make headers clickable on the treeview:
>
>    treeview.set_headers_clickable(True)
>
> --
> Tim Evans
> Applied Research Associates NZ
> http://www.aranz.com/
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>


More information about the pygtk mailing list