On Mon, 21 Feb 2005 13:04:10 +0100
Franck Pommereau <[EMAIL PROTECTED]> threw this fish to the penguins:

> I'm building a PyGTK interface in which I would like that no widget
> would be able to get the focus (and so to be activated by pressing the
> Return key). For this purpose, for each widget, I do:
> 
>     widget.set_property("can-focus", gtk.FALSE)
> 
> My problem is a TreeView which has a clickable column, it get the
> default focus and I did not find how to forbid that.
> 
> I tried:
> 
>     def focus (widget, *args) :
>         try :
>             widget.set_property("can-focus", gtk.FALSE)
>         except :
>             pass
>         try :
>             widget.set_property("can-default", gtk.FALSE)
>         except :
>             pass
>     win.forall(focus)
> 
> where win is my application window (I also tried on the TreeView) but
> it doesn't work.  :-(
> I also tried with widget.unset_flags, same result.  :-((
> 
> If I choose another widget and give it the default focus
> (widget.grab_default and widget.grab_focus) it's OK until I click on
> the column which then keeps the focus.  :-(((
> 
> I'm sure I could capture the Return key but I don't want to have this
> dashed line around the focused widget...
> 
> I think that this column has somewhere an associated widget but I
> could not find it anywhere (and neither could win.forall).

[gtk-2.2.4, but I think this works with earlier 2.x versions]

You have to get a reference to the TreeViewColumn object.
You can do this with:
[http://www.pygtk.org/pygtk2reference/class-gtktreeview.html#method-gtktreeview--get-columns]
  my_treeview.get_column(column_num)
or
  my_treeview.get_columns()

Then use "set_clickable" to turn off sensitivity:
[http://www.pygtk.org/pygtk2reference/class-gtktreeviewcolumn.html#method-gtktreeviewcolumn--set-clickable]

for col in my_treeview.get_columns():
   col.set_clickable(False)

Note that this controls sensitivity only for the column *headers*.

To control the cells, you need to use:
   rend.set_property('editable', False)
for each renderer "rend".

-- George

-- 
"Are the gods not just?"  "Oh no, child.
What would become of us if they were?" (CSL)
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to